import java.io.*; import javax.swing.*; public class LogStream extends OutputStream { OutputStream okstream; public LogStream(OutputStream okstream) { this.okstream = okstream; } static int maxmessage = 400; StringBuffer message = new StringBuffer(); boolean done = false; void accumulate(String s) { if (done) return; message.append(s); if (message.length() > maxmessage) { done = true; ErrorLog.log("Uncaught exception!\n"+ "This means that there was an error that Carto did not expect\n"+ "This may or may not be serious\nThe error messsage started:\n"+ message+"\n"); } } public void write(byte[] b) throws IOException { okstream.write(b); accumulate(new String(b)); } public void write(byte[] b,int off, int len) throws IOException { okstream.write(b,off,len); accumulate(new String(b,off,len)); } public void write(int b) throws IOException { okstream.write(b); byte[] bar = new byte[1]; bar[0]=(byte)b; accumulate(new String(bar)); } public void flush() throws IOException { okstream.flush(); } public void close() throws IOException { okstream.close(); } }