library / org.akop.kotx.tools.basic / ByteArrayBuilder

ByteArrayBuilder

class ByteArrayBuilder

Helper class to assist with building byte arrays. Works similarly to StringBuilder.

Constructors

<init>

ByteArrayBuilder(initialCap: Int = 128)

Helper class to assist with building byte arrays. Works similarly to StringBuilder.

Properties

size

val size: Int

Returns current size of the buffer.

Functions

append

fun append(byte: Byte): Unit

Appends a single byte to the buffer.

fun append(array: ByteArray, srcRange: IntRange = array.indices): Unit

Appends a byte array to the buffer, optionally by only copying a section of it as specified by srcRange.

build

fun build(): ByteArray

Copies the contents of the buffer to a new ByteArray and returns the new array.