首页 > 编程语言 > 详细

java读取配置文件

时间:2015-05-13 13:14:22      阅读:204      评论:0      收藏:0      [点我收藏+]
/**
	 * 读取配置文件
	 * @param file
	 * @return
	 */
	public static PropertiesConfiguration loadConfig(String file){
		PropertiesConfiguration config = null;
		try {
			config = new PropertiesConfiguration(file);
			config.setEncoding("UTF-8");
			config.setReloadingStrategy(new FileChangedReloadingStrategy());
			config.setAutoSave(true);
			logger.info("加载配置文件成功...");
		} catch (ConfigurationException e) {
			logger.info("加载配置文件失败,异常信息:"+e.getLocalizedMessage());
		}
		return config;
	}
public static Configuration config = loadConfig("config.properties");
ConfigUtils.config.getString("weixin.app_id")


java读取配置文件

原文:http://my.oschina.net/cshuangxi/blog/414238

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!