I know that the PrintWriter
is really good if we want to write formatted data, and I also know the use of BufferedWriter
to improve IO performance.
But I tried something like this,
PrintWriter pw = new PrintWriter(System.out);
pw.println("Statement 1");
pw.println("Statement 2");
//pw.flush();
I observed that when the flush method is commented there is no output, but when I uncomment it, I get the desired output.
This is only possible if the PrintWriter is buffered. If so, then what is the point of wrapping a PrintWriter using a BufferedWriter and then writing it?
Though the javadoc doesn't mention anywhere that the PrintWriter is buffered, but it seems so.