org.jclarion.clarion.crash.CrashStream Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of clarion-runtime Show documentation
Show all versions of clarion-runtime Show documentation
JClarion runtime environment
The newest version!
/**
* Copyright 2010, by Andrew Barnham
*
* The contents of this file are subject to
* GNU Lesser General Public License (LGPL), v.3
* http://www.gnu.org/licenses/lgpl.txt
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied.
*/
package org.jclarion.clarion.crash;
import java.io.*;
public class CrashStream extends OutputStream
{
private static int MAX = 256*1024;
private static int MIN = 128*1024;
private OutputStream out;
private StringBuilder buffer;
public CrashStream(OutputStream out)
{
this.out=out;
buffer=new StringBuilder();
Crash.getInstance().setCrashStream(this);
}
@Override
public void write(int b) throws IOException
{
buffer.append((char)b);
prune();
out.write(b);
}
private void prune() {
if (buffer.length()>MAX) {
buffer.delete(0,MIN);
}
}
@Override
public void close() throws IOException {
out.close();
}
@Override
public void flush() throws IOException {
out.flush();
}
@Override
public void write(byte[] b, int off, int len) throws IOException {
for (int scan=0;scan
© 2015 - 2025 Weber Informatics LLC | Privacy Policy