List of utility methods to do Stacktrace Print
void | printStackTrace() print Stack Trace printStackTrace(Thread.currentThread()); |
String | printStackTrace(Exception e) print Stack Trace StringBuilder str = new StringBuilder(); str.append(e + "\r\n"); str.append("-----------------------------------------\r\n"); StackTraceElement[] trace = e.getStackTrace(); for (int i = 0; i < trace.length; i++) { if (trace[i].getLineNumber() == -1) continue; str.append(trace[i] + "\r\n"); ... |
void | printStackTrace(Exception e) print Stack Trace if (e != null) { System.err.print(e.getClass().getName() + "::"); System.err .println((e.getMessage() == null || e.getMessage().equals("")) ? e.toString() : e.getMessage()); StackTraceElement[] elements = e.getStackTrace(); for (int i = 0; i < elements.length; i++) { StackTraceElement element = elements[i]; System.err.println(" - (at " + element.getClassName() + ":" + element.getLineNumber() + ")"); ... |
String | printStackTrace(Exception e) print Stack Trace StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw)); return sw.toString(); |
void | printStackTrace(Exception e) print Stack Trace if (e == null) print(getStackTrace()); else print(stackTraceToString(e.getStackTrace())); |
String | printStackTrace(Exception exception) Prints the stack trace to a string. try { StringWriter stringWriter = new StringWriter(); PrintWriter printWriter = new PrintWriter(stringWriter); exception.printStackTrace(printWriter); return "M: " + exception.getMessage() + " S: " + stringWriter.toString(); } catch (Exception except) { return "Error in printStackTrace: " + except.getMessage(); |
void | printStackTrace(final Exception exception) Synchronized method to ensure message and stack trace are listed consecutively on console. System.out.println("\tA TestUtil runtime exception [" + exception.getMessage() + "] occured."); exception.printStackTrace(); |
void | printStackTrace(final StackTraceElement[] stack) print Stack Trace printStackTrace(stack, System.out); |
void | printStackTrace(IOException ioe) print Stack Trace if (false) {
ioe.printStackTrace();
|
void | printStackTrace(PrintStream out) This is for debugging use only - prints a snapshot of the current stack trace to the given PrintStream . try { throw new RuntimeException(); } catch (RuntimeException dummy) { StackTraceElement[] stack = dummy.getStackTrace(); out.println("CURRENT STACK SNAPSHOT (depth=" + stack.length + " frames)"); for (int i = 1; i < stack.length; i++) { out.println(" -> method " + stack[i - 1].getMethodName() + " in " + stack[i].getFileName() + ", line " + stack[i].getLineNumber()); ... |