Properties工具类

package net.dreamlu.api.util;

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

public class BaseConfig {

    private static Properties props = new Properties();

    static {
        try {
            props.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("config.properties"));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void setProps(Properties prop) {
        props = prop;
    }
    
    public static String getValue(String key) {
        return props.getProperty(key);
    }
}

猜你喜欢

转载自weifengxuxu.iteye.com/blog/2255741