javaee论坛

超级管理员

98

帖子

389

回复

10862

积分

楼主
发表于 2017-05-19 17:18:55 | 查看: 1011 | 回复: 0

import java.util.Enumeration;

import java.util.LinkedHashMap;

import java.util.Properties;

import org.apache.log4j.Logger;

public class ConstantPropertyInfo {

private static Logger log = Logger.getLogger(ConstantPropertyInfo.class);

public static LinkedHashMap<String, String> getInfo(String url) {

LinkedHashMap<String, String> info = new LinkedHashMap<String, String>();

Properties properties = new Properties();

try {

properties.load(ConstantPropertyInfo.class.getClassLoader()

.getResourceAsStream(url));

Enumeration<?> enu = properties.propertyNames();

String key = null;

while (enu.hasMoreElements()) {

key = String.valueOf(enu.nextElement());

info.put(key, properties.getProperty(key));

}

} catch (Exception e) {

log.error("");

}

return info;

}

}

//调用方法

LinkedHashMap<String, String> info = ConstantPropertyInfo.getInfo("路径");

String logo=info.get("logo");



您需要登录后才可以回帖 登录 | 立即注册

触屏版| 电脑版

技术支持 历史网 V2.0 © 2016-2017