您的位置:首页 > 运维架构

读取Properties配置文件

2015-08-25 21:05 399 查看
读取配置文件:

/**
* 通过文件路径载入数据
*
* @param fileName 文件路径
* @return {@link Properties}
*/
public static Properties getPropertiesByFileName(String fileName) {
Properties prop = new Properties();
try (BufferedReader bf = new BufferedReader(new InputStreamReader(PropertiesUtil.class.getClassLoader().getResourceAsStream(fileName), "UTF-8"))) {
if (bf == null) {
return prop;
}
prop.load(bf);
} catch (IOException ex) {
throw new RuntimeException(ex);
}
return prop;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Properties