disconf
disconf copied to clipboard
文件流未关闭会不会有问题
在代码 com.baidu.disconf.client.support.utils.ConfigLoaderUtils#loadWithTomcatMode 没有关闭文件流, 虽然只打开一次. 但是这样写会不会还是不妥
private static Properties loadWithTomcatMode(final String propertyFilePath)
throws Exception {
Properties props = new Properties();
try {
// 先用TOMCAT模式进行导入
// http://blog.csdn.net/minfree/article/details/1800311
// http://stackoverflow.com/questions/3263560/sysloader-getresource-problem-in-java
URL url = ClassLoaderUtil.getLoader().getResource(propertyFilePath);
URI uri = new URI(url.toString());
props.load(new InputStreamReader(new FileInputStream(uri.getPath()), "utf-8"));
} catch (Exception e) {
// http://stackoverflow.com/questions/574809/load-a-resource-contained-in-a-jar
props.load(new InputStreamReader(ClassLoaderUtil.getLoader().getResourceAsStream(propertyFilePath),
"utf-8"));
}
return props;
}