Here you can find the source of stackTraceToString(Throwable e)
Converts a StackTraceElement array to a string.
Parameter | Description |
---|---|
e | The exception thrown. |
public static String stackTraceToString(Throwable e)
//package com.java2s; public class Main { /**// ww w. j av a 2 s. co m * <p> * Converts a StackTraceElement array to a string. * </p> * * @param e The exception thrown. * @return The exception's stack trace as a string. */ public static String stackTraceToString(Throwable e) { StringBuilder sb = new StringBuilder(); for (StackTraceElement element : e.getStackTrace()) { sb.append(element.toString()); sb.append("\n"); } return sb.toString(); } }