import java.io.*;
import javax.swing.*;

public class JTextAreaStream extends OutputStream
{
  protected JTextArea writeTo;

  public JTextAreaStream(JTextArea writeTo)
  {
    if (writeTo == null) throw new NullPointerException();
    this.writeTo = writeTo;
  }

  public void close() {}
  public void flush() {}
  public void write(byte[] b)
  {
    writeTo.append(new String(b));
  }
  public void write(byte[] b, int off, int len)
  {
    writeTo.append(new String(b, off, len));
  }
  public void write(int b)
  {
    writeTo.append((char)b + "");
  }
}

//System.setOut(new PrintStream(new JTextAreaStream(myJTextArea)));
