public RingBuffer append(final char[] ch, int start, int len) {
        // Calculate the current offset for adding data.
        int off = offset + length;
        off = off % buffer.length;

        // len cannot be bigger than the buffer. If it is then limit the array
        // we are pending to only add the last set of characters that will fit
        // into the buffer.
        if (len > buffer.length) {
            start += len - buffer.length;
            len = buffer.length;
        }

        // Now we know how many characters we are adding check to see if the
        // offset needs to move. This is only required if the buffer will
        // overflow when adding the array.
        if (length + len > buffer.length) {
            offset += length + len - buffer.length;
            offset = offset % buffer.length;
        }

        // Now write to the end of the buffer separately if we need to.
        if (off + len > buffer.length) {
            final int rem = buffer.length - off;
            System.arraycopy(ch, start, buffer, off, rem);
            length += rem;
            start += rem;
            len -= rem;
            off = 0;
        }

        // Now write anything else to the start.
        System.arraycopy(ch, start, buffer, off, len);
        length += len;

        // Limit the length.
        if (length > buffer.length) {
            length = buffer.length;
        }

        return this;
    }
Create a buffer with a specified initial size.

@param initialSize The initial size of the buffer.
stroom-pipeline/src/main/java/stroom/pipeline/xml/converter/ds3/RingBuffer.java