dsa

Java BufferedInputStream Class

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

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. As bytes from the stream are read or skipped, the internal buffer is refilled as necessary from the contained input stream, many bytes at a time.

The BufferedInputStream class is a subclass of the Java OutputStream.

declaration

public class BufferedInputStream
   extends FilterInputStream

Constructor and Description

Java BufferedInputStream class method

Sr.No. Method & Description
1 int available()

This method returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking by the next invocation of a method for this input stream.

2 void close()

This method closes this input stream and releases any system resources associated with the stream.

3 void mark(int readlimit)

This method see the general contract of the mark method of InputStream.

4 boolean markSupported()

This method tests if this input stream supports the mark and reset methods.

5 int read()

This method reads the next byte of data from the input stream.

6 int read(byte[] b, int off, int len)

This method reads bytes from this byte-input stream into the specified byte array, starting at the given offset.

7 void reset()

This method repositions this stream to the position at the time the mark method was last called on this input stream.

8 long skip(long n)

This method skips over and discards n bytes of data from this input stream.