put

Relative put: writes a byte at the current position then increments it.


fun put(index: Int, b: Byte): ByteBuffer

Absolute put: writes a byte at the specified index.


Relative bulk put method  (optional operation).

This method transfers the bytes remaining in the given source buffer into this buffer. If there are more bytes remaining in the source buffer than in this buffer, that is, if src.remaining() > remaining(), then no bytes are transferred and a [ ] is thrown.

Otherwise, this method copies n = src.remaining() bytes from the given buffer into this buffer, starting at each buffer's current position. The positions of both buffers are then incremented by n.

In other words, an invocation of this method of the form dst.put(src) has exactly the same effect as the loop

{@snippet lang=java :

  • while (src.hasRemaining())
  •     dst.put(src.get());
  • }

except that it first checks that there is sufficient space in this buffer and it is potentially much more efficient. If this buffer and the source buffer share the same backing array or memory, then the result will be as if the source elements were first copied to an intermediate location before being written into this buffer.

Return

This buffer

Parameters

src

The source buffer from which bytes are to be read; must not be this buffer

Throws

If there is insufficient space in this buffer for the remaining bytes in the source buffer

If the source buffer is this buffer

If this buffer is read-only


fun put(src: ByteArray, offset: Int = 0, length: Int = src.size - offset): ByteBuffer

Bulk put: transfers bytes from the source array into this buffer.