Java BufferedOutputStream class is used for buffering an output stream. It internally uses buffer to store data. It adds more efficiency than to write data directly into a stream. So, it makes the performance fast.
For adding the buffer in an OutputStream, use the BufferedOutputStream class. Let's see the syntax for adding the buffer in an OutputStream:
OutputStream os= new BufferedOutputStream(new FileOutputStream("D:\\IO Package\\testout.txt"));
public class BufferedOutputStream extends OutputStream
|BufferedOutputStream(OutputStream os)||It creates the new buffered output stream which is used for writing the data to the specified output stream.|
|BufferedOutputStream(OutputStream os, int size)||It creates the new buffered output stream which is used for writing the data to the specified output stream with a specified buffer size.|
In this example, we are writing the textual information in the BufferedOutputStream object which is connected to the FileOutputStream object. The flush() flushes the data of one stream and send it into another. It is required if you have connected the one stream with another.
Near fortis Hostipal