spring boot 读取文件

spring 读取文件

    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        InputStream inputStream = classLoader.getResourceAsStream("logback.xml");
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
        StringBuffer buffer = new StringBuffer();
        String line = null;
        while ((line = bufferedReader.readLine()) != null) {
            buffer.append(line).append("\n");
        }
        inputStream.close();
        System.err.println(buffer.toString());

你可能感兴趣的:(spring boot 读取文件)