Here you can find the source of getStackTrace(Throwable e)
public static String getStackTrace(Throwable e)
//package com.java2s; import java.io.PrintWriter; import java.io.StringWriter; public class Main { public static String getStackTrace(Throwable e) { StringWriter out = new StringWriter(); PrintWriter w = new PrintWriter(out); e.printStackTrace(w);/*from w w w . j av a 2 s . com*/ w.flush(); return out.toString(); } public static String getStackTrace(Throwable e, int endIndex) { String stackTrace = getStackTrace(e); if (stackTrace != null && stackTrace.length() > endIndex) { stackTrace = stackTrace.substring(0, endIndex) + "..."; } return stackTrace; } }