java读取资源文件

来源:互联网 发布:转运公司推荐 知乎 编辑:程序博客网 时间:2024/06/10 15:01

配置资源文件为hello.properties

package util;import java.util.ResourceBundle;public class Messages{    private static final String BUNDLE_NAME = "hello";    private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(Messages.BUNDLE_NAME);    public Messages()    {    }    public static String getString(final String key)    {        return Messages.RESOURCE_BUNDLE.getString(key);    }}

 获取方式:

String cnStr = Messages.getString("CONST_STRING_TRAILS");

 

 

 

0 0
原创粉丝点击