Here you can find the source of getStackTrace(Throwable t)
public static String getStackTrace(Throwable t)
//package com.java2s; /*-// www. j a v a2s .c o m * See the file LICENSE for redistribution information. * * Copyright (c) 2002,2010 Oracle. All rights reserved. * */ import java.io.PrintWriter; import java.io.StringWriter; public class Main { /** Return a String version of a stack trace */ public static String getStackTrace(Throwable t) { StringWriter sw = new StringWriter(); t.printStackTrace(new PrintWriter(sw)); String stackTrace = sw.toString(); stackTrace = stackTrace.replaceAll("<", "<"); stackTrace = stackTrace.replaceAll(">", ">"); return stackTrace; } /** Return the stack trace of the caller, for debugging. */ public static String getStackTrace() { Exception e = new Exception(); return getStackTrace(e); } }