java io BufferedOutputStream Class
BufferedOutputStream Class in Java
A BufferedOutputStream is similar to any OutputStream with the exception of an added flush() method that is used to ensure that data buffers are written to the stream being buffered. Since the point of a BufferedOutputStream is to improve performance by reducing the number of times the system actually writes data, you may need to call flush() to cause any data that is in the buffer to be immediately written.
Unlike buffered input, buffering output does not provide additional functionality. Buffers for output in Java are there to increase performance.
java.io.BufferedOutputStream 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".
How to read total bytes from file into array