CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2009
    Posts
    52

    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?

  2. #2
    Join Date
    Feb 2008
    Posts
    966

    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.

  3. #3
    Join Date
    Aug 2009
    Posts
    52

    Re: PrintWriter vs BufferedWriter

    hmm.So can i say generally we should use BufferedWriter?

  4. #4
    Join Date
    May 2006
    Location
    UK
    Posts
    4,473

    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
  •  





Click Here to Expand Forum to Full Width

Featured