List of utility methods to do Stacktrace Print
String | formatStackTrace(Thread thread) format Stack Trace Throwable t = new Throwable( String.format("Stack trace for thread %s (State: %s):", thread.getName(), thread.getState())); t.setStackTrace(thread.getStackTrace()); StringWriter sw = new StringWriter(); t.printStackTrace(new PrintWriter(sw)); return sw.toString(); |
String | formatStackTrace(Throwable t) format Stack Trace StringWriter sw = new StringWriter(); try { PrintWriter p = new PrintWriter(sw); t.printStackTrace(p); } catch (Exception e) { return sw.toString(); |
String | formatStackTrace(Throwable t) Formats a throwable's stack trace if (t == null) return ""; ByteArrayOutputStream baos = new ByteArrayOutputStream(); t.printStackTrace(new PrintStream(baos, true)); try { baos.flush(); } catch (IOException e) { return baos.toString(); |
String | formatStackTrace(Throwable t, String prefix) Formats the stack trace and returns the result. return formatStackTrace(null, t, prefix).toString();
|
String | formatStackTraceToString(Exception ex) format Stack Trace To String if (ex == null) { throw new IllegalArgumentException("ex can't be null."); String result = null; StringWriter stringWriter = null; PrintWriter printWriter = null; try { stringWriter = new StringWriter(); ... |
void | printStackTrace() print Stack Trace for (StackTraceElement ste : Thread.currentThread().getStackTrace()) {
System.out.print(ste);
|
void | printStackTrace() print Stack Trace try { throw new RuntimeException("Debugging purposes only"); } catch (Exception ex) { ex.printStackTrace(); |
void | printStackTrace() Prints the stack trace. final Throwable t = new Throwable(); final StackTraceElement trace[] = t.getStackTrace(); for (final StackTraceElement element : trace) { System.err.println(element.getClassName() + "." + element.getMethodName()); |
void | printStackTrace() print Stack Trace System.out.println("CURRENT STACK TRACE:"); for (StackTraceElement s : Thread.currentThread().getStackTrace()) { System.out.println(s.getClassName() + "." + s.getMethodName() + " (line " + s.getLineNumber() + ") " + (s.isNativeMethod() ? "NATIVE" : "")); System.out.println("END OF STACK TRACE"); |
void | printStackTrace() print Stack Trace StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace(); int cnt = 2; for (StackTraceElement element : stackTraceElements) { if (cnt-- <= 0) System.out.println(" " + element.getClassName() + "." + element.getMethodName() + " (" + element.getFileName() + ":" + element.getLineNumber() + ")"); |