读取properties文件,把内容放到map里

private void setUrlMappingNames() {
String urlName = "";
InputStream in = VisitorProxyManager.class.getClassLoader()
.getResourceAsStream(/messages/policyUrl_zh.properties);
Properties ppt = new Properties();
if (in != null) {
try {
ppt.load(in);
Enumeration<Object> e = ppt.keys();
while (e.hasMoreElements()) {
String key = (String) e.nextElement();
allUrlMappingNames.put(key, ppt.getProperty(key));
}
} catch (IOException e) {
if (logger.isDebugEnabled()) {
logger.debug("读取policyUrl_zh.properties失败!");
}
e.printStackTrace();
}
}
}

你可能感兴趣的:(java)