Here you can find the source of printStackTrace(Throwable t)
public static String printStackTrace(Throwable t)
//package com.java2s; //License from project: LGPL import java.io.*; public class Main { /**/* w w w . j a va2 s .c o m*/ * Use with caution: lots of overhead */ public static String printStackTrace(Throwable t) { StringWriter s = new StringWriter(); PrintWriter p = new PrintWriter(s); t.printStackTrace(p); return s.toString(); } }