Here you can find the source of GetStacktrace(Throwable t)
public static String GetStacktrace(Throwable t)
//package com.java2s; //License from project: Open Source License import java.io.PrintWriter; import java.io.StringWriter; import java.io.Writer; public class Main { public static String GetStacktrace(Throwable t) { final Writer result = new StringWriter(); final PrintWriter printWriter = new PrintWriter(result); boolean first = true; Throwable tt = t;/*from w ww . ja v a 2s . co m*/ do { if (!first) { printWriter.append("Caused by: "); } first = false; tt.printStackTrace(printWriter); } while ((tt = tt.getCause()) != null); return result.toString(); } }