Java Stacktrace stackTrace(StackTraceElement[] stackTrace)

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

Description

stack Trace

License

Apache License

Declaration

public static String stackTrace(StackTraceElement[] stackTrace) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static String stackTrace(StackTraceElement[] stackTrace) {
        StringBuilder str = new StringBuilder("");
        for (StackTraceElement s : stackTrace) {
            str.append("\t").append(s.getClassName() + "." + s.getMethodName() + "(" + s.getFileName() + ":"
                    + s.getLineNumber() + ")" + "\n");
        }/*from  ww w . java2  s .c  om*/
        return str.toString();
    }

    public static String stackTrace(String msg, Throwable throwable) {
        StringBuilder str = new StringBuilder(throwable.getMessage() + " : " + msg + "\n");
        str.append(stackTrace(throwable.getStackTrace()));
        return str.toString();
    }
}

Related

  1. stackTrace()
  2. stacktrace()
  3. stackTrace(final Exception t)
  4. stackTrace(final Throwable caught)
  5. stackTrace(int depth)
  6. stackTrace2String(Throwable e)
  7. stackTraceApproved(StackTraceElement elt, String[] approved)
  8. stackTraceAsString(Throwable t)
  9. stackTraceContainsCause(Throwable throwable, Class searchedCause)