ByteArrayBuilder

class ByteArrayBuilder(initialCapacity: Int = 64)

A minimal growable byte buffer. It is the pure-Kotlin equivalent of a ByteArrayOutputStream, with no java.io dependency, so it lives in commonMain. Amortised O(1) append by doubling. Used by the DEFLATE encoder and the gzip and zlib framers.

Constructors

Link copied to clipboard
constructor(initialCapacity: Int = 64)

Properties

Link copied to clipboard
val size: Int

Number of bytes written so far.

Functions

Link copied to clipboard
fun append(b: Byte)

Append a single byte.

fun append(bytes: ByteArray, offset: Int = 0, length: Int = bytes.size)

Append a slice of bytes.

Link copied to clipboard

Snapshot the written bytes into a right-sized array.