Code example for ByteArrayBuffer

Methods: append, capacity, length

0
            return; 
        } 
        // Do not want to buffer large-ish chunks 
        // if the byte array is larger then MIN_CHUNK_LIMIT 
        // write it directly to the output stream 
        if (len > this.minChunkLimit || len > this.buffer.capacity()) { 
            // flush the buffer 
            flushBuffer(); 
            // write directly to the out stream 
            this.outstream.write(b, off, len); 
            this.metrics.incrementBytesTransferred(len); 
        } else { 
            // Do not let the buffer grow unnecessarily 
            int freecapacity = this.buffer.capacity() - this.buffer.length(); 
            if (len > freecapacity) { 
                // flush the buffer 
                flushBuffer(); 
            } 
            // buffer 
            this.buffer.append(b, off, len); 
        } 
    } 
 
    public void write(final byte[] b) throws IOException { 
        if (b == null) {