SeekableByteChannel

A byte channel that maintains a current position and allows the position to be changed.

A seekable byte channel is connected to an entity, typically a file, that contains a variable-length sequence of bytes that can be read and written. The current position can be queried and modified. The channel also provides access to the current size of the entity to which the channel is connected. The size increases when bytes are written beyond its current size; the size decreases when it is truncated.

The position and truncate methods which do not otherwise have a value to return are specified to return the channel upon which they are invoked. This allows method invocations to be chained. Implementations of this interface should specialize the return type so that method invocations on the implementation class can be chained.

Since

1.7

Functions

Link copied to clipboard
abstract override fun close()

Closes this channel.

Link copied to clipboard
abstract fun isOpen(): Boolean

Tells whether or not this channel is open.

Link copied to clipboard
abstract fun position(): Long

Returns this channel's position.

abstract fun position(newPosition: Long): SeekableByteChannel

Sets this channel's position.

Link copied to clipboard
abstract override fun read(dst: ByteBuffer): Int

Reads a sequence of bytes from this channel into the given buffer.

Link copied to clipboard
abstract fun size(): Long

Returns the current size of entity to which this channel is connected.

Link copied to clipboard
abstract fun truncate(size: Long): SeekableByteChannel

Truncates the entity, to which this channel is connected, to the given size.

Link copied to clipboard
abstract override fun write(src: ByteBuffer): Int

Writes a sequence of bytes to this channel from the given buffer.