static ByteBuffer ensureFreeCapacity(final ByteBuffer buffer, final int capacity) {
        if (buffer == null) {
            return ByteBuffer.allocate(capacity);
        }
        if (buffer.remaining() < capacity) {
            final ByteBuffer newBuffer = ByteBuffer.allocate(buffer.position() + capacity);
            buffer.flip();
            newBuffer.put(buffer);
            return newBuffer;
        }
        return buffer;
    }
Builder class for sequences of bytes.

@since 5.0
ngrinder-runtime/src/main/java/org/apache/hc/client5/http/utils/ByteArrayBuilder.java