List of utility methods to do Throwable to String
String | getStackTrace(Throwable throwable) Gets the stack trace from a Throwable as a String. StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw, true); throwable.printStackTrace(pw); return sw.getBuffer().toString(); |
String | getStackTrace(Throwable throwable) get Stack Trace if (throwable == null) { return "no exception"; } else { ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream(); PrintWriter printwriter = new PrintWriter(new OutputStreamWriter(bytearrayoutputstream)); throwable.printStackTrace(printwriter); printwriter.flush(); printwriter.close(); ... |
String | getStackTrace(Throwable throwable) Get the stack trace of the supplied exception. if (throwable == null) return null; final ByteArrayOutputStream bas = new ByteArrayOutputStream(); final PrintWriter pw = new PrintWriter(bas); throwable.printStackTrace(pw); pw.close(); return bas.toString(); |
String | getStackTrace(Throwable throwable) get Stack Trace if (throwable == null) { return ""; StringWriter swrt = new StringWriter(); PrintWriter pwrt = new PrintWriter(swrt); throwable.printStackTrace(pwrt); return swrt.toString(); |
String | getStackTrace(Throwable thrown) Takes a throwable and puts it's stacktrace into a string. try { Writer writer = new StringWriter(); PrintWriter printWriter = new PrintWriter(writer); thrown.printStackTrace(printWriter); return writer.toString(); } catch (Exception exc) { return ""; |
java.io.ByteArrayOutputStream | getStackTraceAsByteArrayOutputStream(Throwable throwable) get Stack Trace As Byte Array Output Stream java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream(); java.io.PrintWriter pw = new java.io.PrintWriter(baos); throwable.printStackTrace(pw); pw.flush(); return baos; |
String | getStackTraceAsStr(Throwable t) Returns the stack trace of t as a string with each element of the trace separated by a newline character.
StringWriter sw = new StringWriter(2048); PrintWriter writer = new PrintWriter(sw); t.printStackTrace(writer); writer.flush(); return sw.toString(); |
String | getStackTraceAsString(Throwable e) Returns the stack trace of an exception in String form return getStackTraceAsString(e, false);
|
String | getStackTraceAsString(Throwable ex) Prints the stack trace logonservice a String so it can be put on the normal logs. ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream pstr = new PrintStream(baos); if (ex == null) ex = new Exception(); ex.printStackTrace(pstr); return new String(baos.toByteArray()); |
String | getStackTraceAsString(Throwable ex) get Stack Trace As String ByteArrayOutputStream bytes = new ByteArrayOutputStream(); PrintWriter writer = new PrintWriter(bytes, true); writer.println("<h2>" + ex.getMessage() + "</h2><br/>"); ex.printStackTrace(writer); while (true) { ex = ex.getCause(); if (ex != null) { writer.println("<br/><h2>Caused by: " + ex.getMessage() + "</h2><br/>"); ... |