@Override
    public Buffer trimEnd() {
        int initialStart = offset;
        int initialEnd = offset + length - 1;

        int start = initialStart;
        int end = initialEnd;

        while (end >= start && buffer[end] <= SPACE) {
            end--;
        }

        if (end == initialEnd) {
            return this;
        }

        return subSequence(start - initialStart, end - start + 1);
    }
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/CharBuffer.java