Code example for ByteArrayBuffer

Methods: append, clear, length, toByteArray

0
 
    private void deleteUpThrough(int location) {
 
        // int start = location + 1;  // start at the first byte after the location 
 
        byte[] newBuffer = Arrays.copyOfRange(buffer.toByteArray(), location, buffer.length());
        buffer.clear();
        buffer.append(newBuffer, 0, newBuffer.length);
 
    } 
 
    public void appendData(byte[] data) {
 
        if (buffer == null) {
            return; 
        } 
        if (data.length == 0) {
            return; 
        } 
        buffer.append(data, 0, data.length);