home *** CD-ROM | disk | FTP | other *** search
- package netscape.applet;
-
- import java.io.OutputStream;
-
- class ConsoleOutputStream extends OutputStream {
- Console console;
- byte[] doh = new byte[1];
- public static int MAXIMUM_CHARACTERS_IN_CONSOLE;
- public static final int CONSOLE_TRIM_SIZE = 2048;
-
- ConsoleOutputStream(Console console) {
- this.console = console;
- }
-
- public void limitConsoleText(int newCharacterCount) {
- int currentTextLength = this.console.frame.text.getText().length();
- if (MAXIMUM_CHARACTERS_IN_CONSOLE == 0) {
- String consoleMaxCharString = System.getProperty("console.bufferlength", "32768");
- MAXIMUM_CHARACTERS_IN_CONSOLE = Integer.parseInt(consoleMaxCharString);
- }
-
- if (currentTextLength + newCharacterCount > MAXIMUM_CHARACTERS_IN_CONSOLE) {
- this.console.frame.text.replaceText("", 0, 2048);
- }
-
- }
-
- public void write(int b) {
- this.doh[0] = (byte)b;
- String s = new String(this.doh, 0, 0, 1);
- this.limitConsoleText(1);
- this.console.frame.text.insertText(s, 99999);
- }
-
- public void write(byte[] b) {
- String s = new String(b, 0, 0, b.length);
- this.limitConsoleText(b.length);
- this.console.frame.text.insertText(s, 99999);
- }
-
- public void write(byte[] b, int off, int len) {
- String s = new String(b, 0, off, len);
- this.limitConsoleText(len);
- this.console.frame.text.insertText(s, 99999);
- }
- }
-