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

读配置信息 properties

2015-07-01 13:49 176 查看
private static Properties config = null;

static {
InputStream in = getProperties.class.getClassLoader().getResourceAsStream(
"jerseyconfig.properties");//文件名
config = new Properties();
try {
config.load(in);
in.close();
} catch (IOException e) {
System.out.println("No AreaPhone.properties defined error");
}
}

// 根据key读取配置
public static String readValue(String key) {
// Prop
4000
erties props = new Properties();
try {
String value = config.getProperty(key);
return value;
} catch (Exception e) {
e.printStackTrace();
System.err.println("ConfigInfoError" + e.toString());
return null;
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: