public abstract SeekableByteChannel position (long newPosition) throws IOException

Sets this channel's position.

Setting the position to a value that is greater than the current size is legal but does not change the size of the entity. A later attempt to read bytes at such a position will immediately return an end-of-file indication. A later attempt to write bytes at such a position will cause the entity to grow to accommodate the new bytes; the values of any bytes between the previous end-of-file and the newly-written bytes are unspecified.

Setting the channel's position is not recommended when connected to an entity, typically a file, that is opened with the APPEND option. When opened for append, the position is first advanced to the end before writing.

newPosition     The new position, a non-negative integer counting the number of bytes from the beginning of the entity

Returns:  This channel

ClosedChannelException     If this channel is closed
IllegalArgumentException     If the new position is negative
IOException     If some other I/O error occurs