java 读取 properties 配置文件

在项目中经常使用配置文件,跳槽之后公司框架没有这个功能,比较尴尬,自己写一个吧,非常简单,也不用加 jar 包

上代码!!!!

package com.soft.util;

import java.util.ResourceBundle;

public class ReadProperties {

	public static String getValue(String str) {
		String value  = null;
		try {
			ResourceBundle resource = ResourceBundle.getBundle("config");
			value = resource.getString(str);
		}catch (Exception e) {
			e.printStackTrace();
		}
		return value;
	}
}

发布了34 篇原创文章 · 获赞 5 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/qq_36623327/article/details/89162883