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.IOException; import java.io.PrintWriter; import java.io.StringWriter; public class Main { public static String getStackTrace(Throwable t) { StringWriter stringWriter = new StringWriter(); t.printStackTrace(new PrintWriter(stringWriter)); String ret = stringWriter.toString(); try {//from ww w . j a v a2s. c o m stringWriter.close(); } catch (IOException e) { } return ret; } }