黎明前的黑暗
一切不行都是人不行
    /***
     * 解析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;
    }

 

posted on 2019-05-16 14:07  无厘头的小情绪  阅读(165)  评论(0编辑  收藏  举报