java读properties的通用类,兼容linux和windows
package util; import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
/**
* 获取配置文件信息
*
* @author Carl
*
*/
public final class GetProperties {
private static Properties prop = null;
static{
prop = new Properties();
//设置properties文件路径,以src为根路径(config.properties 处于src根目录下)
InputStream in = GetProperties.class.getResourceAsStream("/config.properties");
try {
prop.load(in);
} catch (IOException e) {
System.out.println("读取配置文件失败---->>>>----(/src/config.properties)");//会失败!!!!
e.printStackTrace();
}
} /**
* 根据传入的KEY获取配置文件中对应的值
* @param key
* @return
*/
public static String getPropertieValue(String key){
String value = "";
value = prop.getProperty(key).trim();
return value;
}
} http://nannan408.iteye.com/blog/2022532
java读properties的通用类,兼容linux和windows的更多相关文章
- Java读properties文件中文乱码问题的解决方法
java读properties文件,包含中文字符的主要有两种: 1.key中包含中文字符的(value中也有可能包含) 2.key中不包含中文字符的(value中有可能包含) 1.key中包含中文字符 ...
- java读properties文件 乱码
java读properties文件,包含中文字符的主要有两种: 1.key中包含中文字符的(value中也有可能包含) 2.key中不包含中文字符的(value中有可能包含) 1.key中包含中文字符 ...
- Java 读Properties
import java.io.*; import java.util.Properties; public class Study { public static void main(String[] ...
- Java读取properties文件工具类并解决控制台中文乱码
1.建立properts文件(error.message.properties) HTTP201= 请求成功并且服务器创建了新的资源 2.在spring-mvc.xml文件(applicationCo ...
- Java读取properties配置文件工具类
1. PropertyUtils.java package javax.utils; import java.io.InputStream; import java.util.Properties ...
- java读取properties的工具类PropertiesUtil
package org.properties.util; import java.io.FileInputStream; import java.io.FileOutputStream; import ...
- java获取本机器的IP(linux和windows)
目录 描述 方案描述 获取Windows下的IP 获取linux下的IP 判断操作系统的类型 最后将上面三个方法进行整合 参考 描述 由于项目是部署在集群上的,需要项目能够自动采集各机器的信息.jav ...
- 个人项目-WC(C/C++ 兼容Linux和Windows)
一.Github地址 https://github.com/S-TRAVELER/WC 实现的功能: 支持 -c 支持 -w 支持 -l 支持 -s 支持 -a 图形界面 多参数(文件名或通配符表达式 ...
- phantomjs的使用+Java代码+依赖js(兼容Linux和windows版本)
1. 在使用phantomjs的时候需要下载phantomjs,网上有window版本和Linux版本.将phantomjs放在Linux上的指定位置之后(如下面的/home/tpl/phantom ...
随机推荐
- 关于appstore多语言版本,不可不看!
http://www.cocoachina.com/appstore/20160513/16256.html
- 动态创建地图文档MXD并发布地图服务
原文:动态创建地图文档MXD并发布地图服务 1.动态创建MXD private bool CreateMxd(string MxdPath, string MxdName) { IMapDocumen ...
- 用字体在网页中画icon小图标
HTML结构: <i class="icons icon-ui"> 㐺 <i> <i class="icons icon-ui"& ...
- 昂贵的聘礼---poj1062(最短路)
题目链接:http://poj.org/problem?id=1062 题意很清楚: 可以虚拟一个起点0,由于存在等级关系,所以可以枚举等级,然后把各种关系建立边,然后计算0到1的距离即可,去最小值即 ...
- iOS 获取当前时间 年、月、日、周几
NSDate * nowDate = [NSDate new]; NSCalendar *calendar = [NSCalendar currentCalendar]; NSUInteger uni ...
- SMART Goals
Once you have planned your project, turn your attention to developing several goals that will enable ...
- WPF数据库连接错误:The user is not associated with a trusted SQL Server connection.
我当初安装sql server的时候选的Window Authentication mode,没选SQL Server Windows Authentication. 后来做WPF时连接数据库时需要一 ...
- Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. For example: Given the below binary tree andsum =
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all ...
- @MyBatis中的if...else...
<select id="selectSelective" resultMap="xxx" parameterType="xxx"> ...
- .NET中常见对象类型
.NET中六大内置对象:1.Response 2.Request 3.Session 4.Appliction 5.Server 6.Cookie System.Web.HttpCo ...