litesoft
@ 939
litesoft / trunk / Java / core / Anywhere / src / org / litesoft / commonfoundation / exceptions / 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 |
// This Source Code is in the Public Domain per: http://litesoft.org/License.txt package org.litesoft.commonfoundation.exceptions; 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"; @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/Java/core/Anywhere/src/org/litesoft/commonfoundation/exceptions/ExceptionStackTracePrintStream.java
Revision | Author | Commited | Message |
---|---|---|---|
939 Diff | GeorgeS | Mon 02 Jun, 2014 21:30:31 +0000 | Extracting commonfoundation |
58 Diff | markcmarkc | Thu 08 Jul, 2010 00:27:39 +0000 | |
50 Diff | GeorgeS | Tue 13 Apr, 2010 11:51:38 +0000 | |
49 Diff | GeorgeS | Mon 12 Apr, 2010 02:59:10 +0000 | License Text |
2 | GeorgeS | Sun 07 Feb, 2010 12:50:58 +0000 |