01: package com.knowgate.debug;
02:
03: import java.io.Writer;
04: import java.io.StringWriter;
05: import java.io.PrintWriter;
06: import java.io.IOException;
07:
08: /**
09: * Simple utility to return the stack trace of an exception as a String.
10: * @author John O'Hanley
11: * @version 1.0
12: */
13: public final class StackTraceUtil {
14:
15: public static String getStackTrace(Throwable aThrowable)
16: throws IOException {
17: final Writer result = new StringWriter();
18: final PrintWriter printWriter = new PrintWriter(result);
19: aThrowable.printStackTrace(printWriter);
20: String sRetVal = result.toString();
21: printWriter.close();
22: result.close();
23: return sRetVal;
24: }
25: }
|