hugo84
October 16th, 2009, 10:11 AM
Whats the difference between a PrintWriter and a BufferedWriter. In what cases should we use them? or can we just choose anyone of them?
|
Click to See Complete Forum and Search --> : PrintWriter vs BufferedWriter hugo84 October 16th, 2009, 10:11 AM Whats the difference between a PrintWriter and a BufferedWriter. In what cases should we use them? or can we just choose anyone of them? ProgramThis October 16th, 2009, 10:47 AM Directly from the BufferedWriter class: Without buffering, each invocation of a print() method would cause characters to be converted into bytes that would then be written immediately to the file, which can be very inefficient. Another thing is that the PrintWriter does not have the ability to write raw bytes at a time, which if you need to encode the message you cannot do. hugo84 October 17th, 2009, 08:03 AM hmm.So can i say generally we should use BufferedWriter? keang October 17th, 2009, 09:27 AM They are not really comparable classes. A BufferedWriter is a wrapper class to provide buffering to any object of type Writer. A PrintWriter is a specialised type of Writer that to quote the API docs "Prints formatted representations of objects to a text-output stream" codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |