In Java, what is the advantage of using BufferedWriter to append to a file?

前端 未结 3 1754
遇见更好的自我
遇见更好的自我 2020-12-10 15:24

I\'m looking at the following example

Which uses the following code

try {
      BufferedWriter out = new BufferedWriter(new FileWriter(\"outfilename\         


        
3条回答
  •  既然无缘
    2020-12-10 16:04

    this is explained in the javadocs for outputstreamwriter. a filewriter does have a buffer (in the underlying outputstreamwriter), but the character encoding converter is invoked on each call to write. using an outer buffer avoids calling the converter so often.

    http://download.oracle.com/javase/1.4.2/docs/api/java/io/OutputStreamWriter.html

提交回复
热议问题