|
-
October 16th, 2009, 10:11 AM
#1
PrintWriter vs BufferedWriter
Whats the difference between a PrintWriter and a BufferedWriter. In what cases should we use them? or can we just choose anyone of them?
-
October 16th, 2009, 10:47 AM
#2
Re: PrintWriter vs BufferedWriter
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.
-
October 17th, 2009, 08:03 AM
#3
Re: PrintWriter vs BufferedWriter
hmm.So can i say generally we should use BufferedWriter?
-
October 17th, 2009, 09:27 AM
#4
Re: PrintWriter vs BufferedWriter
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"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|