java io BufferedInputStream Class
BufferedInputStream Class in Java
A BufferedInputStream adds functionality to another input stream-namely, the ability to buffer the input and to support the mark and reset methods. When the BufferedInputStream is created, an internal buffer array is created. The internal buffer is refilled as necessary from the contained input stream, many bytes at a time. The mark operation remembers a point in the input stream and the reset operation causes all the bytes read since the most recent mark operation to be reread before new bytes are taken from the contained input stream.
Buffering I/O is a very common performance optimization. Java’s BufferedInputStream class allows you to "wrap" any InputStream into a buffered stream to improve performance.
java.io.BufferedInputStream class Example
The above program output may look a little different from what you expected because System.in is line buffered, by default. This means that no input is actually passed to the program until you press ENTER. As you can guess, this does not make read() particularly valuable for interactive console input.
The following program demonstrates BufferedReader and the readLine() method; the program reads and displays lines of text until you enter the word "stop".
java.io.BufferedInputStream class Example 2
How to read total bytes from file into array using java BufferedInputStream