File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Question regarding the buffer created with BufferedReader class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Question regarding the buffer created with BufferedReader class" Watch "Question regarding the buffer created with BufferedReader class" New topic
Author

Question regarding the buffer created with BufferedReader class

Moieen Khatri
Ranch Hand

Joined: Nov 27, 2007
Posts: 144
Hi,

Can some please let me know what exactly is the buffer which is created using the BufferedReader class? Is all the data read into the Buffer first before writing data to the file? What is the advantage of this buffering and why is it requried?

Thanks,
Moieen
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41843
    
  63
Welcome to JavaRanch.

The Javadocs of BufferedReader and BufferedWriter mention the benefits of using them, and what the buffer is and does; basically, it can be good for performance. As such, it's optional to use buffers, but not required.


Ping & DNS - my free Android networking tools app
Kelvin Chenhao Lim
Ranch Hand

Joined: Oct 20, 2007
Posts: 513
Basically, I/O buffering (at least for disk media) reduces the number of number of physical seek/read/write operations that have to be performed, which usually leads to a significant increase in performance.

You can tell BufferedReader to use a specific buffer size by passing the size to its constructor. Otherwise, it will use an implementation-specific default value (a typical value would be something like 8192 bytes). If your file is no larger than the buffer size, then the entire file will indeed be read into memory all at once.


SCJP 5.0
Moieen Khatri
Ranch Hand

Joined: Nov 27, 2007
Posts: 144
thanks for the help guys.... I am clear about this concept now

Cheers,
Moieen
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question regarding the buffer created with BufferedReader class