package net.hxtek.util;
import java.io.IOException;
/**
* 读取Properties文件枚举类
* 2014-3-13 下午2:12:18
*
*/
public enum PropUtil {
SMS("SMS", "sms.properties");
private String key;
private String path;
private Properties props;
PropUtil(String key, String path) {
this.key = key;
this.path = path;
}
public Properties getProp() {
if (props == null) {
initProps();
}
return props;
}
public String getKey() {
return key;
}
public String getPath() {
return path;
}
private synchronized void initProps() {
InputStream in = null;
props=new Properties();
try {
props.load(PropFile.class.getClassLoader().getResourceAsStream("/" + path));
} catch (IOException e) {
e.printStackTrace();
} finally {
if (in != null) {
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
读取多个Properties文件
最新推荐文章于 2021-09-06 18:25:05 发布