【Java】读取文件内容InputStream

【Java】读取文件内容InputStream

    /**
     * 读取文件内容
     * @return String
     * @author xinhui.chen
     * @updateTime 2022/9/28
     */
    private String readFromInputStream(InputStream inputStream)
            throws IOException {
        StringBuilder resultStringBuilder = new StringBuilder();
        try (BufferedReader br
                     = new BufferedReader(new InputStreamReader(inputStream))) {
            String line;
            while ((line = br.readLine()) != null) {
                resultStringBuilder.append(line).append("\n");
            }
        }
        return resultStringBuilder.toString();
    }
LICENSED UNDER CC BY-NC-SA 4.0