Here you can find the source of printStackTrace(Throwable t)
public static String printStackTrace(Throwable t)
//package com.java2s; import java.io.PrintWriter; import java.io.StringWriter; public class Main { public static String printStackTrace(Throwable t) { StringWriter strWriter = new StringWriter(); PrintWriter printWriter = new PrintWriter(strWriter); if (t != null) { t.printStackTrace(printWriter); }// w w w . j a va2 s.c o m return strWriter.getBuffer().toString(); } }