阅读背景:

以流的形式读取properties配置文件

来源:互联网 
@Slf4j
public class PropertiesUtil {


    private static Properties props;

    static {
        String fileName = "wechat.properties";
        props = new Properties();
        try {
            props.load(new InputStreamReader(PropertiesUtil.class.getClassLoader().getResourceAsStream(fileName),"UTF-8"));
        } catch (IOException e) {
            log.error("配置文件读取异常",e);
        }
    }

    public static String getProperty(String key){
        String value = props.getProperty(key.trim());
        if(StringUtils.isBlank(value)){
            return null;
        }
        return value.trim();
    }

    public static String getProperty(String key,String defaultValue){

        String value = props.getProperty(key.trim());
        if(StringUtils.isBlank(value)){
            value = defaultValue;
        }
        return value.trim();
    }



}@Slf4j
public class PropertiesUtil {


    priv



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: