Here you can find the source of getStackTrace(Throwable t)
public static final String getStackTrace(Throwable t)
//package com.java2s; /*// w w w . j a v a2s. c o m * ADOBE SYSTEMS INCORPORATED * Copyright 2007 Adobe Systems Incorporated All Rights Reserved * * NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the * terms of the Adobe license agreement accompanying it. If you have received this file from a * source other than Adobe, then your use, modification, or distribution of it requires the prior * written permission of Adobe. */ import java.io.PrintWriter; import java.io.StringWriter; public class Main { public static final String getStackTrace(Throwable t) { if (t != null) { StringWriter stringWritter = new StringWriter(); PrintWriter printWritter = new PrintWriter(stringWritter, true); t.printStackTrace(printWritter); printWritter.flush(); stringWritter.flush(); return stringWritter.toString(); } return ""; } }