put

fun ByteBuffer.put(source: ByteArray, sourceOffset: Int = 0, kapacity: Kapacity): ByteBuffer

Writes up to the specified kapacity of bytes from the source array into this buffer.

Warning on Bounds: This operation safely clamps the number of bytes written to prevent BufferOverflowException and IndexOutOfBoundsException. The actual number of bytes transferred will be the minimum of: the requested kapacity, the ByteBuffer.remaining space in this buffer, or the available data in the source array accounting for the sourceOffset.

Return

This buffer, to allow for fluent method chaining.

Parameters

source

The byte array containing the data to write.

sourceOffset

The index within the source array to begin reading from. Defaults to 0.

kapacity

The maximum amount of data to write into this buffer.