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;
    }
原文地址:https://www.cnblogs.com/dreamzhiya/p/4832561.html