List of utility methods to do Throwable to String
String | stackTrace(final Throwable t) Return the stack trace for the given throwable as a string. final ByteArrayOutputStream out = new ByteArrayOutputStream(); getRootException(t).printStackTrace(new PrintWriter(out, true)); return out.toString(); |
void | stacktrace(Logger logger, Throwable ex) Print the stacktrace for the exception in the logfile. if (logger.isDebugEnabled()) { logger.debug("*******************************************************************"); logger.debug(ex.getLocalizedMessage()); StackTraceElement[] ste = ex.getStackTrace(); if (ste != null && ste.length > 0) { for (StackTraceElement st : ste) { logger.debug(st.getClassName() + "." + st.getMethodName() + "() [" + st.getFileName() + ":" + st.getLineNumber() + "]"); ... |
String | stackTrace(Throwable cause) stack Trace ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(byteArrayOutputStream); PrintStream printStream = new PrintStream(bufferedOutputStream); cause.printStackTrace(printStream); printStream.flush(); return byteArrayOutputStream.toString(); |
String | stackTrace(Throwable e) stack Trace try { ByteArrayOutputStream trace = new ByteArrayOutputStream(); PrintStream dump = new PrintStream(trace, true, "utf8"); e.printStackTrace(dump); return trace.toString("utf8"); } catch (Exception shouldNotHappen) { throw new RuntimeException(shouldNotHappen); |
String | stackTrace(Throwable e) Returns the output of printStackTrace as a String. String throwableAsString = null; try { ByteArrayOutputStream buf = new ByteArrayOutputStream(); e.printStackTrace(new PrintWriter(buf, true)); throwableAsString = buf.toString(); } catch (Exception f) { return throwableAsString; ... |
String | stackTrace(Throwable e) stack Trace StringWriter buf = new StringWriter(); e.printStackTrace(new PrintWriter(buf)); return buf.toString(); |
String | stackTrace(Throwable e) Returns a string containing the representation of the stack trace of the exception StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw, true); e.printStackTrace(pw); pw.flush(); sw.flush(); return sw.toString(); |
String | stackTrace(Throwable exception) Returns the stack trace of an Throwable as a String .
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); PrintStream printStream = new PrintStream(outputStream); exception.printStackTrace(printStream); return outputStream.toString(); |
String | stackTrace(Throwable t) stack Trace StringWriter sw = new StringWriter(0); PrintWriter pw = new PrintWriter(sw); t.printStackTrace(pw); pw.close(); return sw.getBuffer().toString(); |
String | stackTrace(Throwable t) stack Trace String s = null; try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); t.printStackTrace(new PrintWriter(baos, true)); s = baos.toString(); } catch (Exception e) { return s; ... |