class TextAreaOutputStream extends OutputStream {

    /**
     * The text area to which we want to write.
     */
    protected JTextArea text;
    /**
     * Keeps track of the offset of the text in the text area.
     */
    protected int offset;

    /**
     * Constructs a TextAreaOutputStream.
     *
     * @param text the text area to which we want to write.
     */
    public TextAreaOutputStream(JTextArea text) {
        this.text = text;
        clear();
    }

    /**
     * Clear the text area.
     */
    public void clear() {
        text.setText(null);
        offset = 0;
    }

    /**
     * @see java.io.OutputStream#write(int)
     */
    @Override
    public void write(int i) throws IOException {
        byte[] b = {(byte) i};
        write(b, 0, 1);
    }

    /**
     * @see java.io.OutputStream#write(byte[], int, int)
     */
    @Override
    public void write(byte[] b, int off, int len) {<FILL_FUNCTION_BODY>}

    /**
     * @see java.io.OutputStream#write(byte[])
     */
    @Override
    public void write(byte[] b) throws IOException {
        ByteArrayInputStream bais = new ByteArrayInputStream(b);
        byte[] snippet = new byte[1024];
        int bytesread;
        while ((bytesread = bais.read(snippet)) > 0) {
            write(snippet, 0, bytesread);
        }
    }

}

        String snippet = new String(b, off, len);
        text.insert(snippet, offset);
        offset += len - off;
    
<methods>public void <init>() ,public void close() throws java.io.IOException,public void flush() throws java.io.IOException,public static java.io.OutputStream nullOutputStream() ,public abstract void write(int) throws java.io.IOException,public void write(byte[]) throws java.io.IOException,public void write(byte[], int, int) throws java.io.IOException<variables>