获取 properties的值

来源:互联网 发布:深圳华夏软件学校骗 编辑:程序博客网 时间:2024/06/01 07:33
package cn.necsthz.lvshitong.util;import java.io.IOException;import java.io.InputStream;import java.util.Properties;public class MobliePropertiesUtil {    private static String fileName = "/moblie.properties";    private static Properties p = new Properties();    static {        InputStream in = null;        try {            in = MobliePropertiesUtil.class.getResourceAsStream(fileName);// 类加载器            p.load(in);        } catch (Exception e) {            e.printStackTrace();        } finally {            try {                in.close();            } catch (IOException e) {                e.printStackTrace();            }        }    }    public static String get(String key) {        String value = null;        if (p.containsKey(key)) {            value = p.getProperty(key);        }        return value;    }}

0 0
原创粉丝点击