Ask a Teacher



In java what is the use of bufferred reader in a program?


The BufferedReader class provides buffering to your Reader's. Buffering can speed up IO quite a bit. Rather than read one character at a time from the network or disk, you read a larger block at a time. This is typically much faster, especially for disk access and larger data amounts.

The main difference between BufferedReader and BufferedInputStream is that Reader's work on characters (text), wheres InputStream's works on raw bytes.

To add buffering to your Reader's simply wrap them in a BufferedReader. Here is how that looks:

Reader input = new BufferedReader(
new FileReader("c:\\data\\input-file.txt"));


comments powered by Disqus