Here you can find the source of getStackTrace(Throwable t)
public static String getStackTrace(Throwable t)
//package com.java2s; import java.io.PrintWriter; import java.io.StringWriter; public class Main { public static String getStackTrace(Throwable t) { if (t != null) { StringWriter stringWriter = new StringWriter(); PrintWriter printWriter = new PrintWriter(stringWriter); t.printStackTrace(printWriter); return stringWriter.toString(); }/*w w w.j a va2 s .c o m*/ return ""; } public static String getStackTrace(Thread thread) { StringBuffer sb = new StringBuffer(); StackTraceElement[] trace = thread.getStackTrace(); for (int i = 0; i < trace.length; i++) sb.append("\tat " + trace[i] + "\r\n"); return sb.toString(); } }