Here you can find the source of formatStackTrace(Throwable t)
public static String formatStackTrace(Throwable t)
//package com.java2s; import java.io.PrintWriter; import java.io.StringWriter; public class Main { public static String formatStackTrace(Throwable t) { StringWriter sw = new StringWriter(); try {// w w w .j a v a 2 s . c om PrintWriter p = new PrintWriter(sw); t.printStackTrace(p); } catch (Exception e) { } return sw.toString(); } }