Should I buffer the InputStream or the InputStreamReader?

后端 未结 4 2098

What are the differences (if any) between the following two buffering approaches?

Reader r1 = new BufferedReader(new InputStreamReader(in, \"UTF-8\"), bufferSize         


        
4条回答
  •  北恋
    北恋 (楼主)
    2021-02-05 03:47

    FWIW, if you're opening a file in Java 8, you can use the Files.newBufferedReader(Path). I don't know how the performance compares to the other solutions described here, but at least it pushes the decision of what construct to buffer into the JDK.

提交回复
热议问题