01: /*
02: * @(#)TextAreaOutputStream.java 1.2 04/12/06
03: *
04: * Copyright (c) 1997-2004 Sun Microsystems, Inc. All Rights Reserved.
05: *
06: * See the file "LICENSE.txt" for information on usage and redistribution
07: * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
08: */
09:
10: package org.pnuts.awt;
11:
12: import java.awt.TextArea;
13: import java.io.IOException;
14: import java.io.OutputStream;
15:
16: /**
17: * Output stream to a TextArea
18: */
19: public class TextAreaOutputStream extends OutputStream {
20: TextArea textArea;
21:
22: public TextAreaOutputStream(TextArea textArea) {
23: this .textArea = textArea;
24: }
25:
26: public void write(int b) throws IOException {
27: char a[] = { (char) b };
28: String s = new String(a);
29: textArea.append(s);
30: }
31:
32: public void write(byte b[], int off, int len) throws IOException {
33: String s = new String(b, off, len);
34: textArea.append(s);
35: }
36:
37: public void close() throws IOException {
38: textArea = null;
39: }
40: }
|