okio / okio / Buffer / <init>

<init>

(js, jvm, native) <init>()

A collection of bytes in memory.

Moving data from one buffer to another is fast. Instead of copying bytes from one place in memory to another, this class just changes ownership of the underlying byte arrays.

This buffer grows with your data. Just like ArrayList, each buffer starts small. It consumes only the memory it needs to.

This buffer pools its byte arrays. When you allocate a byte array in Java, the runtime must zero-fill the requested array before returning it to you. Even if you’re going to write over that space anyway. This class avoids zero-fill and GC churn by pooling byte arrays.