litesoft
@ 936
litesoft / trunk / DeviceDesktopTest / src / org / litesoft / core / util / ExceptionStackTracePrintStream.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
// This Source Code is in the Public Domain per: http://litesoft.org/License.txt package org.litesoft.core.util; import java.io.*; /** * A print stream which can be passed to * {@link Throwable#printStackTrace(PrintStream)}. Only the minimally necessary * methods for this use are implemented. */ public class ExceptionStackTracePrintStream extends PrintStream { private final StringBuilder mStringBuilder = new StringBuilder(); public ExceptionStackTracePrintStream() { super( OutputStreamStub.INSTANCE ); } @Override public void println( Object x ) { mStringBuilder.append( x ); mStringBuilder.append( "\r\n" ); } @Override public void println( String x ) { mStringBuilder.append( x ); mStringBuilder.append( "\r\n" ); } @Override public String toString() { return mStringBuilder.toString(); } @SuppressWarnings("NullableProblems") private static class OutputStreamStub extends OutputStream { public static final OutputStreamStub INSTANCE = new OutputStreamStub(); private static final String MESSAGE = "FIXME: this method should never be called"; @Override public void write( int b ) { throw new AssertionError( MESSAGE ); } @Override public void write( byte[] b ) { throw new AssertionError( MESSAGE ); } @Override public void write( byte[] b, int off, int len ) { throw new AssertionError( MESSAGE ); } @Override public void flush() { throw new AssertionError( MESSAGE ); } @Override public void close() { throw new AssertionError( MESSAGE ); } } } |
Commits for litesoft/trunk/DeviceDesktopTest/src/org/litesoft/core/util/ExceptionStackTracePrintStream.java
Revision | Author | Commited | Message |
---|---|---|---|
936 | GeorgeS | Sun 01 Jun, 2014 20:19:38 +0000 | Language Support |