Java Stacktrace to String stackTraceToString(StackTraceElement[] stackTrace)

Here you can find the source of stackTraceToString(StackTraceElement[] stackTrace)

Description

stack Trace To String

License

Open Source License

Declaration

public static String stackTraceToString(StackTraceElement[] stackTrace) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static String stackTraceToString(StackTraceElement[] stackTrace) {
        StringBuilder sb = new StringBuilder();
        for (StackTraceElement element : stackTrace) {
            sb.append(element.toString()).append(" (")
                    .append(element.getLineNumber()).append(")");
            sb.append("\n");
        }/*from  w w w.  j  av  a 2s. co m*/
        return sb.toString();
    }

    public static String stackTraceToString(Throwable e) {
        return stackTraceToString(e.getStackTrace());
    }
}

Related

  1. stackTraceToString(Exception exception)
  2. stackTraceToString(final StackTraceElement[] stackTrace)
  3. stackTraceToString(final Throwable t, final boolean header, final boolean trim)
  4. stacktraceToString(final Throwable throwable)
  5. stacktraceToString(StackTraceElement[] s)
  6. stackTraceToString(StackTraceElement[] stackTrace)
  7. stackTraceToString(StackTraceElement[] stackTrace, StringBuilder buf)
  8. stackTraceToString(StackTraceElement[] ste)
  9. stackTraceToString(StackTraceElement[] trace)