欢迎进入Java社区论坛,与200万技术人员互动交流 >>进入
/**
* 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;
}
只要看得开放得下,何愁没有快乐的春莺在啼鸣,