Java获取.properties配置文件某一项value根据key值

    public static String getProperty(String key){
        InputStream in = PropertiesUtils.class.getResourceAsStream("/conf.properties");
        Properties properties = new Properties();
        String value;
        try {
            properties.load(in);
            value = properties.getProperty(key);
            in.close();
            return value;
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }

 

posted @ 2015-09-23 16:06  阿尔法钻石狗  阅读(1407)  评论(0)    收藏  举报