Java Utililty Methods Dump Stracktrace

List of utility methods to do Dump Stracktrace

Description

The list of methods to do Dump Stracktrace are organized into topic(s).

Method

voiddumpCurrentStackTrace(PrintStream out)
Used to track down which tests are still doing things that should really be done only in development
for (StackTraceElement e : Thread.currentThread().getStackTrace()) {
    System.out.println("\t" + e);
StringdumpStack()
Method dumpStack.
return dumpStack(new Throwable());
voiddumpStack(boolean exit)
dump Stack
try {
    throw new Exception("Dumping stack:");
} catch (Exception e) {
    e.printStackTrace();
voiddumpStack(final PrintStream out, final int skip, final int depth)
dump Stack
dumpStack(out, new Exception(""), skip + 1, depth);
StringdumpStackTrace(int depth)
dump Stack Trace
StringBuilder sb = new StringBuilder();
StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
for (int i = 0; i < stackTrace.length && i < depth; i++) {
    StackTraceElement se = stackTrace[i];
    sb.append(" - " + se.getClassName() + "#" + se.getMethodName() + ":" + se.getLineNumber() + "\n");
return sb.toString();