Java examples for java.lang:Exception
Convert Stack Trace in Throwable to String
import java.io.PrintWriter; import java.io.StringWriter; public class Main{ public static String getStackTrace(Throwable th) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); th.printStackTrace(pw);/*ww w. j a v a 2 s. co m*/ pw.close(); return sw.toString(); } }