The BufferedInputStream class of java.io package 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 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.
BufferedInputStream Class Syntax
public class InputStreamReader
BufferedInputStream Class Compatibility Version
InputStreamReader Class is available since Java 1.0
Basic Usage of BufferedInputStream
The BufferedInputStream class as part of the java.io package provides additional methods thus it makes this class more versatility compared other classes that deals with Stream. If you don’t need methods such as mark() and reset(), then InputStreamReader class is one of the option that you can choose from.
BufferedInputStream Method Usage Examples
The following are the detailed list of BufferedInputStream methods and descriptions. We have also provided links to examples of each method on the list.
|Modifier and Type||Method and Description|
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.
Closes this input stream and releases any system resources associated with the stream.
See the general contract of the mark method of InputStream.
Tests if this input stream supports the mark and reset methods.
See the general contract of the read method of InputStream.
|int||read(byte b, int off, int len)
Reads bytes from this byte-input stream into the specified byte array, starting at the given offset.
See the general contract of the reset method of InputStream.
See the general contract of the skip method of InputStream.