java - PrintWriter vs FileWriter in the following context -


this question has answer here:

what if in next bit of code going substitute (new filewriter (new printwriter

pw = new printwriter(new bufferedwriter(new filewriter  ("xanaduindeed.txt")));  pw = new printwriter(new bufferedwriter(new printwriter ("xanaduindeed.txt"))); 

both of them work fine, know of 2 optimize memory usage. (if either of 2 better) in advance.

in oracle's jvm:

public printwriter(string filename) throws filenotfoundexception {     this(new bufferedwriter(new outputstreamwriter(new fileoutputstream(filename))),          false); } 

printwriter's notable characteristic flush output on every newline (lf or cr or crlf). lowest memory footprint bare filewriter, buffering gives notable improvement in i/o performance.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -