/***
     * 解析properties文件配置
     * @param pathName 解析文件名称
     * @param elementName 解析字段
     * @return 返回解析字段的值
     */
    public static Object initProperties(String pathName, String elementName) {
        Properties properties = new Properties();
        String path = Common.class.getClassLoader().getResource(pathName).getPath();
        File file = new File(path);
        try {
            FileInputStream inputStream = new FileInputStream(file);
            InputStreamReader inputStreamReader = new InputStreamReader(inputStream, "utf-8");

            properties.load(inputStreamReader);
            return properties.getProperty(elementName);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }

 

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。