litesoft
@ 964
litesoft / trunk / GWT_Sandbox / FormEngine / src / com / temp / common / shared / utils / 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 |
package com.temp.common.shared.utils; 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(); } 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"; public void write( int b ) { throw new AssertionError( MESSAGE ); } public void write( byte[] b ) { throw new AssertionError( MESSAGE ); } public void write( byte[] b, int off, int len ) { throw new AssertionError( MESSAGE ); } public void flush() { throw new AssertionError( MESSAGE ); } public void close() { throw new AssertionError( MESSAGE ); } } } |
Commits for litesoft/trunk/GWT_Sandbox/FormEngine/src/com/temp/common/shared/utils/ExceptionStackTracePrintStream.java
Revision | Author | Commited | Message |
---|---|---|---|
964 | GeorgeS | Fri 01 Aug, 2014 03:18:23 +0000 | ! |