write

open fun write(src: ByteBuffer): Int

Writes bytes from the given byte buffer to this channel.

The bytes are written starting at the channel's current position, and after some number of bytes are written (up to the remaining number of bytes in the buffer) the channel's position is increased by the number of bytes actually written.

If the channel's position is beyond the current end of the underlying data source, then the data source is first extended up to the given position by the required number of unspecified byte values.

Return

the number of bytes actually written.

Parameters

buffer

the byte buffer containing the bytes to be written.

Throws

if the channel was not opened for writing.

if the channel was already closed.

if another thread closes the channel during the write.

if another thread interrupts the calling thread while this operation is in progress. The interrupt state of the calling thread is set and the channel is closed.

if another I/O error occurs, details are in the message.