Here you can find the source of getStackTraceAsString(Throwable t)
Parameter | Description |
---|---|
t | the Throwable from which to extract the stack trace |
public static String getStackTraceAsString(Throwable t)
//package com.java2s; import java.io.PrintWriter; import java.io.StringWriter; public class Main { /**/*from w w w. j a va2 s. c o m*/ * Given a Throwable, this method returns a String representation of the * complete stack trace. * * @param t the Throwable from which to extract the stack trace * @return a String representation of the stack trace */ public static String getStackTraceAsString(Throwable t) { if (t != null) { StringWriter sw = new StringWriter(); PrintWriter writer = new PrintWriter(sw); t.printStackTrace(writer); return sw.getBuffer().toString(); } else { return ""; } } }