Java Stacktrace stacktrace()

Here you can find the source of stacktrace()

Description

stacktrace

License

Open Source License

Return

a String showing the current stack

Declaration

public static String stacktrace() 

Method Source Code

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

public class Main {
    /**//from   w  w  w  .j  ava2  s .c om
     * @return a String showing the current stack
     */
    public static String stacktrace() {
        try {
            throw new Exception();
        } catch (Exception e) {
            StackTraceElement[] trace = e.getStackTrace();
            StringBuilder sb = new StringBuilder();
            for (int i = 1; i < trace.length; i++) {
                StackTraceElement stackTraceElement = trace[i];
                sb.append(stackTraceElement.toString());
                sb.append('\n');
            }
            return sb.toString();
        }
    }
}

Related

  1. deeplyPrint(Throwable e, PrintStream strm, boolean stackTrace)
  2. stackTrace()
  3. stackTrace()
  4. stackTrace()
  5. stackTrace()
  6. stackTrace(final Exception t)
  7. stackTrace(final Throwable caught)
  8. stackTrace(int depth)