dsa

Java BufferedOutputStream Class

In this tutorial, we will learn about Java BufferedOutputStream and its methods with the help of examples.

Java.io.BufferedOutputStream class implements a buffered output stream. By setting up such an output stream, an application can write bytes to the underlying output stream without necessarily causing a call to the underlying system for each byte written.

The BufferedOutputStream class is a subclass of the Java OutputStream.

declaration

public class BufferedOutputStream
   extends FilterOutputStream

Constructor and Description

  • BufferedOutputStream(OutputStream out) : Creates a new buffered output stream to write data to the specified underlying output stream.
  • BufferedOutputStream(OutputStream out, int size) : Creates a new buffered output stream to write data to the specified underlying output stream with the specified buffer size.

Java BufferedOutputStream class method

Sr.No. Method & Description
1 void flush()

This method flushes this buffered output stream.

2 void write(byte[] b, int off, int len)

This method writes len bytes from the specified byte array starting at offset off to this buffered output stream.

3 void write(int b)

This method writes the specified byte to this buffered output stream.