BufferedInputStream

open class BufferedInputStream @JvmOverloads constructor(in: InputStream, size: Int = DEFAULT_BUFFER_SIZE) : FilterInputStream

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 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.

Author

Arthur van Hoff

Since

1.0

Constructors

Link copied to clipboard
constructor(in: InputStream, size: Int = DEFAULT_BUFFER_SIZE)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
open override fun available(): Int

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. The next invocation might be the same thread or another thread. A single read or skip of this many bytes will not block, but may read or skip fewer bytes.

Link copied to clipboard
open override fun close()

Closes this input stream and releases any system resources associated with the stream. Once the stream has been closed, further read(), available(), reset(), or skip() invocations will throw an IOException. Closing a previously closed stream has no effect.

Link copied to clipboard
open override fun mark(readlimit: Int)

See the general contract of the mark method of InputStream.

Link copied to clipboard
open override fun markSupported(): Boolean

Tests if this input stream supports the mark and reset methods. The markSupported method of BufferedInputStream returns true.

Link copied to clipboard
open override fun read(): Int

See the general contract of the read method of InputStream.

open override fun read(b: ByteArray, off: Int, len: Int): Int

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

open override fun read(b: ByteArray): Int

Reads up to b.length bytes of data from this input stream into an array of bytes. This method blocks until some input is available.

Link copied to clipboard
open fun readAllBytes(): ByteArray?

Reads all remaining bytes from the input stream. This method blocks until all remaining bytes have been read and end of stream is detected, or an exception is thrown. This method does not close the input stream.

Link copied to clipboard
open fun readNBytes(len: Int): ByteArray?

Reads up to a specified number of bytes from the input stream. This method blocks until the requested number of bytes has been read, end of stream is detected, or an exception is thrown. This method does not close the input stream.

open fun readNBytes(b: ByteArray, off: Int, len: Int): Int

Reads the requested number of bytes from the input stream into the given byte array. This method blocks until len bytes of input data have been read, end of stream is detected, or an exception is thrown. The number of bytes actually read, possibly zero, is returned. This method does not close the input stream.

Link copied to clipboard
open override fun reset()

See the general contract of the reset method of InputStream.

Link copied to clipboard
open override fun skip(n: Long): Long

See the general contract of the skip method of InputStream.

Link copied to clipboard
open fun skipNBytes(n: Long)

Skips over and discards exactly n bytes of data from this input stream. If n is zero, then no bytes are skipped. If n is negative, then no bytes are skipped. Subclasses may handle the negative value differently.

Link copied to clipboard
open override fun transferTo(out: OutputStream): Long

Reads all bytes from this input stream and writes the bytes to the given output stream in the order that they are read. On return, this input stream will be at end of stream. This method does not close either stream.