@@ -0,0 +1,2445 @@
+package hudson.util;%0A%0Aimport java.io.OutputStream;%0Aimport java.io.IOException;%0Aimport java.io.ByteArrayOutputStream;%0Aimport java.io.InputStream;%0A%0A/**%0A * %7B@link ByteArrayOutputStream%7D re-implementation.%0A *%0A * %3Cp%3E%0A * This version allows one to read while writing is in progress. %0A *%0A * @author Kohsuke Kawaguchi%0A */%0Apublic class ByteBuffer extends OutputStream %7B%0A    private byte%5B%5D buf = new byte%5B8192%5D;%0A    /**%0A     * Size of the data.%0A     */%0A    private int size = 0;%0A%0A%0A    public synchronized void write(byte b%5B%5D, int off, int len) throws IOException %7B%0A        ensureCapacity(len);%0A        System.arraycopy(b,off,buf,size,len);%0A        size+=len;%0A    %7D%0A%0A    public synchronized void write(int b) throws IOException %7B%0A        ensureCapacity(1);%0A        buf%5Bsize++%5D = (byte)b;%0A    %7D%0A%0A    public synchronized long length() %7B%0A        return size;%0A    %7D%0A%0A    private void ensureCapacity(int len) %7B%0A        if(buf.length-size%3Elen)%0A            return;%0A%0A        byte%5B%5D n = new byte%5BMath.max(buf.length*2, size+len)%5D;%0A        System.arraycopy(buf,0,n,0,size);%0A        this.buf = n;%0A    %7D%0A%0A    public synchronized String toString() %7B%0A        return new String(buf,0,size);%0A    %7D%0A%0A    /**%0A     * Creates an %7B@link InputStream%7D that reads from the underlying buffer.%0A     */%0A    public InputStream newInputStream() %7B%0A        return new InputStream() %7B%0A            private int pos = 0;%0A            public int read() throws IOException %7B%0A                synchronized(ByteBuffer.this) %7B%0A                    if(pos%3E=size)   return -1;%0A                    return buf%5Bpos++%5D;%0A                %7D%0A            %7D%0A%0A            public int read(byte b%5B%5D, int off, int len) throws IOException %7B%0A                synchronized(ByteBuffer.this) %7B%0A                    if(size==pos)%0A                        return -1;%0A%0A                    int sz = Math.min(len,size-pos);%0A                    System.arraycopy(buf,pos,b,off,sz);%0A                    pos+=sz;%0A                    return sz;%0A                %7D%0A            %7D%0A%0A%0A            public int available() throws IOException %7B%0A                synchronized(ByteBuffer.this) %7B%0A                    return size-pos;%0A                %7D%0A            %7D%0A%0A            public long skip(long n) throws IOException %7B%0A                synchronized(ByteBuffer.this) %7B%0A                    int diff = (int) Math.min(n,size-pos);%0A                    pos+=diff;%0A                    return diff;%0A                %7D%0A            %7D%0A        %7D;%0A    %7D%0A%7D%0A

implemented a custom byte buffer.