SeekableByteChannel

An interface for channels that keep a pointer to a current position within an underlying byte-based data source such as a file.

SeekableByteChannels have a pointer into the underlying data source which is referred to as a position. The position can be manipulated by moving it within the data source, and the current position can be queried.

SeekableByteChannels also have an associated size. The size of the channel is the number of bytes that the data source currently contains. The size of the data source can be manipulated by adding more bytes to the end or by removing bytes from the end. See truncate, position and write for details. The current size can also be queried.

Since

1.7

Inheritors

Functions

Link copied to clipboard
abstract fun close()

abstract fun close()
Closes an open channel.
Link copied to clipboard
abstract fun isOpen(): Boolean
Returns true if this channel is open.
Link copied to clipboard
abstract fun position(): Long
Returns the current position as a positive number of bytes from the start of the underlying data source.
abstract fun position(newPosition: Long): SeekableByteChannel
Sets the channel's position to newPosition.
Link copied to clipboard
abstract fun read(buffer: ByteBuffer): Int
Reads bytes from this channel into the given buffer.
Link copied to clipboard
abstract fun size(): Long
Returns the size of the data source underlying this channel in bytes.
Link copied to clipboard
abstract fun truncate(size: Long): SeekableByteChannel
Truncates the data source underlying this channel to a given size.
Link copied to clipboard
abstract fun write(buffer: ByteBuffer): Int
Writes bytes from the given byte buffer to this channel.