KByteArrayInputStream

Constructors

Link copied to clipboard
constructor(data: ByteArray, context: KnioContext)

Types

Link copied to clipboard
object Companion

Functions

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

Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without suspending for an I/O operation, which may be 0, or 0 when end of stream is detected.

Link copied to clipboard
Link copied to clipboard
open suspend override fun close()

Closes this resource, relinquishing any underlying resources.

Link copied to clipboard
suspend fun KInputStream.copyTo(output: OutputStream, bufferSize: Int = DEFAULT_BUFFER_SIZE): Long
suspend fun KInputStream.copyTo(output: KOutputStream, bufferSize: Int = DEFAULT_BUFFER_SIZE): Long

Copies this input stream to the specified output stream.

Link copied to clipboard
open suspend fun mark(readLimit: Int)

Marks the current position in the input stream.

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

Tests if this input stream supports the mark and reset methods. Whether or not mark and reset are supported is an invariant property of a particular input stream instance.

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

open suspend fun read(): Int

Reads the next byte of data from the input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.

open suspend fun read(b: ByteArray): Int

Reads some number of bytes from the input stream and stores them into the buffer array b. The number of bytes actually read is returned as an integer. This method blocks until input data is available, end of file is detected, or an exception is thrown.

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

Reads up to len bytes of data from the input stream into an array of bytes. An attempt is made to read as many as len bytes, but a smaller number may be read. The number of bytes actually read is returned as an integer.

Link copied to clipboard
open suspend 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
suspend fun KInputStream.reader(charset: Charset = Charsets.UTF_8): KInputStreamReader
Link copied to clipboard
open suspend fun readNBytes(len: Int): ByteArray

Reads up to a specified number of bytes from the input stream. This method reads 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 suspend 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. I n the case where end of stream is reached before len bytes have been read, then the actual number of bytes read will be returned. When this stream reaches end of stream, further invocations of this method will return zero.

Link copied to clipboard
open suspend fun reset()

Repositions this stream to the position at the time the mark method was last called on this input stream. The general contract of reset is:

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