java 项目 读取properties配置文件

 public static String getPath() {
        String filePath = null;
        InputStream in = null;
        try {
            Properties properties = new Properties();
            in = ReadExcelUtil.class.getClassLoader().getResourceAsStream("util.properties");
            properties.load(in);
            filePath = properties.getProperty("ExcelFilepath");
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                if (in != null) in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return filePath;
    }

猜你喜欢

转载自blog.csdn.net/qq_38553333/article/details/80455930