您的位置:首页 > 编程语言 > Java开发

java读取属性文件

2012-12-28 11:48 309 查看
/**

* 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;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: