get

fun get(): Byte

Relative get: reads the byte at the current position then increments it.


fun get(index: Int): Byte

Absolute get: returns the byte at the given index (without modifying position).


open fun get(index: Int, dst: ByteArray, offset: Int, length: Int): ByteBuffer

Absolute bulk get method.

This method transfers length bytes from this buffer into the given array, starting at the given index in this buffer and at the given offset in the array. The position of this buffer is unchanged.

An invocation of this method of the form src.get(index, dst, offset, length) has exactly the same effect as the following loop except that it first checks the consistency of the supplied parameters and it is potentially much more efficient:

{@snippet lang=java :

  • for (int i = offset, j = index; i < offset + length; i++, j++)
  •     dst[i] = src.get(j);
  • }

Return

This buffer

Since

13

Parameters

index

The index in this buffer from which the first byte will be read; must be non-negative and less than limit()

dst

The destination array

offset

The offset within the array of the first byte to be written; must be non-negative and less than dst.length

length

The number of bytes to be written to the given array; must be non-negative and no larger than the smaller of limit() - index and dst.length - offset

Throws

If the preconditions on the index, offset, and length parameters do not hold


fun get(dst: ByteArray, offset: Int = 0, length: Int = dst.size - offset): ByteBuffer

Bulk get: transfers remaining bytes into the given destination array.