无框架读取config.properties

package com.xxx.utils;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class ConfigUtils {



    public static String getValue(String key) {
        Properties properties = new Properties();
        //InputStream isInputStream = this.getClass().getClassLoader().getResourceAsStream("config.properties");
        InputStream isInputStream = ConfigUtils.class.getClassLoader().getResourceAsStream("config.properties");
        try {
            properties.load(isInputStream);
        } catch (IOException e) {
            e.printStackTrace();
        }
        //System.out.println(properties.getProperty(key));
        return properties.getProperty(key);
    }

}

©️2020 CSDN 皮肤主题: 游动-白 设计师:上身试试 返回首页