加载配置文件

来源:互联网 发布:Windows测试udp 编辑:程序博客网 时间:2024/04/30 02:43

配置文件-需放在资源文件目录下

这里写图片描述

import java.util.Locale;import java.util.ResourceBundle;public class ProxyConfig {    private static Locale locale=null;    private static ResourceBundle cache=null;    static {        try {            locale=Locale.getDefault();                 cache=ResourceBundle.getBundle("proxy_authService",locale);        } catch (RuntimeException e){            e.printStackTrace();        }    }    /** 读取配置文件     *  @param key     *  @return     * */    public static String getKey(String key){        if(key!=null&&!key.equals("")){            return cache.getString(key);        }        return "";    }}
0 0