Here you can find the source of getStackTraceString(Throwable t)
public static List getStackTraceString(Throwable t)
//package com.java2s; import java.io.ByteArrayOutputStream; import java.io.PrintStream; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; public class Main { public static List getStackTraceString(Throwable t) { List lines = new ArrayList(); try {//from ww w .java2 s .com ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); t.printStackTrace(ps); String stackTraces = baos.toString(); StringTokenizer st = new StringTokenizer(stackTraces, "\n"); while (st.hasMoreTokens()) { lines.add(st.nextToken()); } } catch (Exception e) { e.printStackTrace(System.err); lines.add("X:" + e); } return lines; } }