List of utility methods to do Stacktrace Print
String | printStackTrace(Throwable throwable) print Stack Trace 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'); if (throwable.getCause() != null) { return sb.toString() + printStackTrace(throwable.getCause()); } else { ... |
void | printStackTrace(Throwable throwable) Prints the given stacktrace if (DEBUG) {
throwable.printStackTrace();
|
String | printStackTraceAsHtml(Throwable t) Formats a subset of a throwable's stack trace as HTML. StackTraceElement[] stes = t.getStackTrace(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < stes.length && i <= MAX_STACK_FRAME; i++) { sb.append(" ").append(stes[i].getClassName()).append(":") .append(stes[i].getLineNumber()).append(": ").append(stes[i].getMethodName()).append("<br/>"); if (MAX_STACK_FRAME < stes.length - 1) { sb.append(" ...<br/>"); ... |
void | printStackTraceElement(StackTraceElement element, StringBuilder buffer) IMprime un stacktrace element. buffer.append(element.getClassName()); buffer.append('.'); buffer.append(element.getMethodName()); buffer.append('('); buffer.append(element.getFileName()); if (element.getLineNumber() > 0) { buffer.append(':'); buffer.append(element.getLineNumber()); ... |
String | printStackTraceHTML(Throwable e) print Stack Trace HTML final StringBuilder buf = new StringBuilder(); final StackTraceElement[] trace = e.getStackTrace(); buf.append("<table id=\"javatrace\">"); buf.append("<caption>Java Stack Trace:</caption>"); buf.append("<tr><th>Class Name</th><th>Method Name</th><th>File Name</th><th>Line</th></tr>"); for (int i = 0; i < trace.length && i < 20; i++) { buf.append("<tr>"); buf.append("<td class=\"class\">").append(trace[i].getClassName()).append("</td>"); ... |
void | printStackTraces() Print a string representation of the current stack state of all the active threads. printStackTraces(new PrintWriter(new OutputStreamWriter(System.err))); |
void | printStackTraceToOutputStream(Throwable t, OutputStream out) print Stack Trace To Output Stream PrintWriter writer = new PrintWriter(out); try { t.printStackTrace(writer); } finally { writer.flush(); |
String | printStackTraceToString(final Throwable t) print Stack Trace To String try (StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw);) { t.printStackTrace(pw); pw.flush(); sw.flush(); return sw.toString(); |
String | printStackTraceToString(Throwable aThrowable) Return a String containing the printed stacktrace of an exception. StringWriter swriter = new StringWriter(); PrintWriter writer = new PrintWriter(swriter, true); aThrowable.printStackTrace(writer); writer.close(); return swriter.toString(); |
String | printStackTraceUsingStream(Throwable throwable) print Stack Trace Using Stream ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); throwable.printStackTrace(ps); return baos.toString(); |