java读取属性文件
/**
* nc
* 读取属性文件
* @param path
* @param Key
* @return
*/
public static String getPropertiesValue(String path,String Key){
path="../classes/resource/jdbc-config/jdbc.properties";
String _value = Key;
try {
URL configs = Thread.currentThread().getContextClassLoader().getResource(path);//"../classes/resource/jdbc-config/jdbc.properties"
InputStream is = configs.openStream();
Properties pro = new Properties();
pro.load(is);
_value = pro.getProperty(Key);
} catch (Exception e) {
e.fillInStackTrace();
}
if(StringUtils.isBlank(_value)){
_value="";
}
return _value;
}
补充:软件开发 , Java ,