Monday, 25 April 2016

How to print stacktrace of exception manually ?


Call getStackTrace() method of exception and iterate over elements.

Example
StackTraceElement[] elements = exception.getStackTrace();
for (int j = 0; j < elements.length; j++) {
  System.out.println(elements[j].toString());

}

No comments:

Post a Comment

Note: only a member of this blog may post a comment.