Here you can find the source of getStackTrace(Throwable exception)
public static String getStackTrace(Throwable exception)
//package com.java2s; import java.io.PrintWriter; import java.io.StringWriter; public class Main { public static String getStackTrace(Throwable exception) { StringWriter sw = null;//from www . ja v a 2 s .co m PrintWriter pw = null; try { sw = new StringWriter(); pw = new PrintWriter(sw); exception.printStackTrace(pw); return sw.toString(); } finally { if (pw != null) { pw.close(); } } } }