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?
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 - updated with new look and Ping home screen widget
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.
Joined: Nov 27, 2007
thanks for the help guys.... I am clear about this concept now