Here you can find the source of stackTraceToString(Throwable throwable)
Parameter | Description |
---|---|
throwable | Throwable to process. |
public static String stackTraceToString(Throwable throwable)
//package com.java2s; //License from project: Open Source License import java.io.PrintWriter; import java.io.StringWriter; import java.io.Writer; public class Main { /**//from w ww . j a v a2 s . c om * Retrieve the stack trace from the given Throwable, and output the string. * * @param throwable Throwable to process. * @return String output of the thorwable's stack trace. */ public static String stackTraceToString(Throwable throwable) { final Writer result = new StringWriter(); final PrintWriter printWriter = new PrintWriter(result); throwable.printStackTrace(printWriter); return result.toString(); } }