Here you can find the source of getStackTraceString(Throwable tr)
public static String getStackTraceString(Throwable tr)
//package com.java2s; //License from project: Apache License import java.io.PrintWriter; import java.io.StringWriter; public class Main { public static String getStackTraceString(Throwable tr) { if (tr == null) { return ""; }//from www .j a v a2s. c o m Throwable t = tr; while (t.getCause() != null) { t = t.getCause(); } StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); t.printStackTrace(pw); pw.flush(); return sw.toString(); } }