Buffer
Constructors
Types
Functions
Discard count readable bytes.
Read the next byte or fail with EOFException if it's not available. The returned byte is marked as consumed.
Reserve endGap bytes in the end. Could move readPosition and writePosition to reserve space but only when no bytes were written or all written bytes are marked as consumed (were read or discarded).
Reserve startGap bytes in the beginning. May move readPosition and writePosition if no bytes available for reading.
Marks the whole buffer available for read and no for write
Marks all capacity writable except the start gap reserved before. The end gap reservation is discarded.
Rewind readPosition backward to make count bytes available for reading again.
Peek the next unsigned byte or return -1
if no more bytes available for reading. No bytes will be marked as consumed in any case.
Read the next unsigned byte or return -1
if no more bytes available for reading. The returned byte is marked as consumed.
Write a byte value at writePosition (incremented when written successfully).
Properties
Write position limit. No bytes could be written ahead of this limit. When the limit is less than the capacity then this means that there are reserved bytes in the end (endGap). Such a reserved space in the end could be used to write size, hash and so on. Also it is useful when several buffers are connected into a chain and some primitive value (e.g. kotlin.Int
) is separated into two chunks so bytes from the second chain could be copied to the reserved space of the first chunk and then the whole value could be read at once.
Current read position. It is always non-negative and will never run ahead of the writePosition. It is usually greater or equal to startGap reservation. This position is affected by discard, rewind, resetForRead, resetForWrite, reserveStartGap and reserveEndGap.
Current write position. It is always non-negative and will never run ahead of the limit. It is always greater or equal to the readPosition.
Inheritors
Extensions
Read available for read bytes to the destination array range starting at array offset and length bytes. If less than length bytes available then less bytes will be copied and the corresponding number will be returned as result.
Read available for read bytes to the destination array range starting at array offset and length elements. If less than length elements available then less elements will be copied and the corresponding number will be returned as result (possibly zero).
Read a floating point number or fail if not enough bytes available for reading. The numeric value is decoded in the network order (Big Endian).
Read from this buffer to the destination array to offset and length bytes.
Read from this buffer to the destination array to offset and length bytes. Numeric values are interpreted in the network byte order (Big Endian).
Read buffer's content to the destination buffer moving its position.
Read an unsigned short integer or fail if not enough bytes available for reading. The numeric value is decoded in the network order (Big Endian).
Write a floating point number or fail if not enough space available for writing. The numeric value is encoded in the network order (Big Endian).
Write a floating point number or fail if not enough space available for writing. The numeric value is encoded in the network order (Big Endian).
Write the whole source array range staring at offset and having the specified items length. Numeric values are interpreted in the network byte order (Big Endian).
Write all readable bytes from src to this buffer. Fails if not enough space available to write all bytes.
Write source buffer content moving its position.
Write a short integer or fail if not enough space available for writing. The numeric value is encoded in the network order (Big Endian).
Write an unsigned byte or fail if not enough space available for writing.
Write an unsigned long integer or fail if not enough space available for writing. The numeric value is encoded in the network order (Big Endian).
Write an unsigned short integer or fail if not enough space available for writing. The numeric value is encoded in the network order (Big Endian).