public byte[] toByteArray() {
        if (this.buffer == null) {
            return new byte[] {};
        }
        this.buffer.flip();
        final byte[] b = new byte[this.buffer.remaining()];
        this.buffer.get(b);
        this.buffer.clear();
        return b;
    }
Builder class for sequences of bytes.

@since 5.0
httpclient5/src/main/java/org/apache/hc/client5/http/utils/ByteArrayBuilder.java