Here you can find the source of getStackTrace(Throwable t)
Parameter | Description |
---|---|
t | The <code>Throwable</code>. |
printStackTrace(PrintWriter)
method.
public static String getStackTrace(Throwable t)
//package com.java2s; import java.io.*; public class Main { /**/*from w ww . ja v a2 s . c o m*/ * A convenient way of extracting the stack trace from an * exception. * * @param t The <code>Throwable</code>. * @return The stack trace as generated by the exception's * <code>printStackTrace(PrintWriter)</code> method. */ public static String getStackTrace(Throwable t) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw, true); t.printStackTrace(pw); return sw.getBuffer().toString(); } }