Java BufferedInputStream
In Java, the BufferedInputStream
class is a subclass of the FilterInputStream
that provides buffering functionality to an input stream. It reads data from an underlying input stream and stores it in an internal buffer for faster access.
Here are some of the commonly used methods of the BufferedInputStream
class:
read()
: This method reads a single byte of data from the input stream.read(byte[] b)
: This method reads up tob.length
bytes of data from the input stream into an array of bytes.read(byte[] b, int off, int len)
: This method reads up tolen
bytes of data from the input stream into an array of bytes starting at the specified offsetoff
.skip(long n)
: This method skips over and discardsn
bytes of data from the input stream.available()
: This method returns an estimate of the number of bytes that can be read from the input stream without blocking.mark(int readLimit)
: This method marks the current position in the input stream and sets the read limit toreadLimit
.reset()
: This method resets the input stream to the position marked by themark()
method.markSupported()
: This method returns a boolean value indicating whether themark()
andreset()
methods are supported by the input stream.close()
: This method closes the input stream and releases any system resources associated with it.
It's important to note that the BufferedInputStream
class should be used with caution when reading from untrusted sources, as it can be vulnerable to malicious attacks if the data is not properly validated.