position

open fun position(): Long

Returns this channel's position.

This method violates the contract of position as it will not throw any exception when invoked on a closed channel. Instead it will return the position the channel had when close has been called.


open fun position(newPosition: Long): SeekableByteChannel

Sets the channel's position to newPosition.

The argument is the number of bytes counted from the start of the data source. The position cannot be set to a value that is negative. The new position can be set beyond the current size. If set beyond the current size, attempts to read will return end-of-file. Write operations will succeed but they will fill the bytes between the current end of the data source and the new position with the required number of (unspecified) byte values.

Return

the channel.

Throws

if the new position is negative.

if this channel is closed.

if another I/O error occurs.


open fun position(channelNumber: Long, relativeOffset: Long): SeekableByteChannel

set the position based on the given channel number and relative offset

Return

global position of all channels as if they are a single channel

Parameters

channelNumber

the channel number

relativeOffset

the relative offset in the corresponding channel

Throws

if positioning fails