Java Stacktrace Print printStackTrace(Throwable throwable)

Here you can find the source of printStackTrace(Throwable throwable)

Description

print Stack Trace

License

Apache License

Declaration

public static String printStackTrace(Throwable throwable) 

Method Source Code

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

public class Main {
    public static String printStackTrace(Throwable throwable) {
        StringBuilder sb = new StringBuilder();
        sb.append("Caused by: ").append(throwable).append('\n');
        for (StackTraceElement ste : throwable.getStackTrace()) {
            sb.append('\t').append(ste.toString()).append('\n');
        }//from   w  w w  .  ja  va2  s.c  o m
        if (throwable.getCause() != null) {
            return sb.toString() + printStackTrace(throwable.getCause());
        } else {
            return sb.toString();
        }
    }
}

Related

  1. printStackTrace(Throwable exception)
  2. printStackTrace(Throwable t)
  3. printStackTrace(Throwable t)
  4. printStackTrace(Throwable t)
  5. printStackTrace(Throwable throwable)
  6. printStackTraceAsHtml(Throwable t)
  7. printStackTraceElement(StackTraceElement element, StringBuilder buffer)
  8. printStackTraceHTML(Throwable e)
  9. printStackTraces()