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.PrintWriter; import java.io.StringWriter; public class Main { public static String getStackTrace(Throwable t) { Throwable cur = t;/* www. j ava 2 s . c o m*/ String stacktrace = "--- Exception Details ---\r\n"; while (cur != null) { StringWriter sw = new StringWriter(); t.printStackTrace(new PrintWriter(sw)); stacktrace += t.getMessage() + "\r\n" + sw.toString(); cur = t.getCause(); if (cur != null) { stacktrace += "\r\n-- Caused by -- \r\n"; } } return stacktrace; } }