FileReadableStream

class FileReadableStream @JvmOverloads constructor(file: File, dispatcher: CoroutineDispatcher = Dispatchers.IO) : ReadableStream

Constructors

Link copied to clipboard
fun FileReadableStream(file: File, dispatcher: CoroutineDispatcher = Dispatchers.IO)

Properties

Link copied to clipboard
open override var currentOffset: UInt

Number of already read bytes.

Functions

Link copied to clipboard
open override fun close()

Clearing memory and closing handles. After calling this method, all other methods will return ReadableStreamHasClosedException.

Link copied to clipboard
open override fun getLength(): UInt

Returns the number of bytes in the stream. If length is unknown, UInt.MAX_VALUE will be returned.

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

Check is there more data in the stream.

Link copied to clipboard
open suspend override fun read(): UByte

Reads and returns a byte from the stream, indented by currentOffset.

Link copied to clipboard
open suspend override fun readAll(): UByteArray

Returns all data in one byte array and closes itself.

Link copied to clipboard
open suspend override fun readBlock(blockSize: UShort): UByteArray

Reads and returns up to blockSize next bytes from the stream or an empty array if stream has ran out. Result array could has less size if there is less data remains in the stream.

Extensions