ByteBuffer

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The byte order. Defaults to BIG_ENDIAN.

Link copied to clipboard

The fixed capacity of this ByteBuffer.

Link copied to clipboard
var limit: Int

The limit, i.e. the upper bound (exclusive) for read/writes.

Link copied to clipboard
Link copied to clipboard

The current position. Must be between 0 and limit.

Functions

Link copied to clipboard

port of java.nio.ByteBuffer.array() Returns byte array that backs this buffer.

Link copied to clipboard

Returns the offset within this buffer's backing array of the first element of the buffer  (optional operation).

Link copied to clipboard

Creates a view of this byte buffer as a float buffer.

Link copied to clipboard
Link copied to clipboard

Creates a view of this byte buffer as a long buffer.

Link copied to clipboard

Creates a new, read-only byte buffer that shares this buffer's content.

Link copied to clipboard

Clears the buffer: sets position to 0, limit to capacity, and mark to -1.

Link copied to clipboard

Compacts this buffer  (optional operation).

Link copied to clipboard
open operator override fun compareTo(other: ByteBuffer): Int

Compares the remaining bytes lexicographically.

Link copied to clipboard

Creates a new buffer that shares this buffer’s content but has independent position, limit, and mark.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard

Flips the buffer: sets limit to current position and resets position to 0.

Link copied to clipboard
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).

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

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

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

Absolute bulk get method.

Link copied to clipboard
fun getInt(): Int

Relative get method for reading an int value.

fun getInt(index: Int): Int

Absolute get method for reading an int value.

Link copied to clipboard
fun getLong(): Long

Relative get method for reading a long value.

fun getLong(index: Int): Long

Absolute get method for reading a long value.

Link copied to clipboard

Relative get method for reading a short value.

fun getShort(index: Int): Short

Absolute get method for reading a short value.

Link copied to clipboard

Tells whether or not this buffer is backed by an accessible byte array. For this implementation, we always return true since we can always create and return a byte array copy of the buffer contents.

Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard

Tells whether there are any elements between the current position and the limit.

Link copied to clipboard

true if mutation is disallowed

Link copied to clipboard
fun limit(newLimit: Int): ByteBuffer

Sets this buffer's limit.

Link copied to clipboard

Sets the mark at the current position.

Link copied to clipboard

Returns this buffer’s current byte order.

Modifies this buffer's byte order.

Link copied to clipboard
fun position(newPosition: Int): ByteBuffer

Sets this buffer's position. If the mark is defined and larger than the new position then it is discarded.

Link copied to clipboard

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

Relative bulk put method  (optional operation).

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

Absolute put: writes a byte at the specified index.

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

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

Link copied to clipboard
fun putBuffer(pos: Int, src: ByteBuffer, srcPos: Int, n: Int)
Link copied to clipboard
fun putInt(value: Int): ByteBuffer

Relative put method for writing an int value  (optional operation).

Link copied to clipboard
fun putLong(value: Long): ByteBuffer
Link copied to clipboard

Relative put method for writing a short value  (optional operation).

Link copied to clipboard
fun remaining(): Int

Returns the number of bytes remaining between position and limit.

Link copied to clipboard

Resets the position to the previously set mark.

Link copied to clipboard

Rewinds the buffer: resets position to 0 without changing limit.

Link copied to clipboard

Creates a new buffer that is a view of this buffer's content between position and limit.

Link copied to clipboard
open override fun toString(): String