List of utility methods to do Throwable to String
String | getStackTraceAsString(Throwable t) Gets the stack trace of the Throwable passed in as a string.
ByteArrayOutputStream stackTraceBIS = new ByteArrayOutputStream(); t.printStackTrace(new PrintStream(stackTraceBIS)); return new String(stackTraceBIS.toByteArray()); |
String | getStackTraceAsString(Throwable t) get Stack Trace As String if (t != null) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); t.printStackTrace(pw); final String stackTraceAsString = sw.toString(); try { sw.close(); } catch (IOException e) { ... |
String | getStackTraceAsString(Throwable t) Prints the Throwable object's stack trace into a string, so that it can be safely printed without the possibility of throwing an exception final Writer sw = new StringWriter(); t.printStackTrace(new PrintWriter(sw)); return sw.toString(); |
String | getStackTraceAsString(Throwable t) Given a Throwable, this method returns a String representation of the complete stack trace. if (t != null) { StringWriter sw = new StringWriter(); PrintWriter writer = new PrintWriter(sw); t.printStackTrace(writer); return sw.getBuffer().toString(); } else { return ""; |
String | getStackTraceAsString(Throwable throwable) get Stack Trace As String StringWriter stringWriter = new StringWriter(); throwable.printStackTrace(new PrintWriter(stringWriter)); return stringWriter.toString(); |
String | getStackTraceAsString(Throwable throwable) Returns a string containing the result of Throwable#toString() toString() , followed by the full, recursive stack trace of throwable . StringWriter stringWriter = new StringWriter(); throwable.printStackTrace(new PrintWriter(stringWriter)); return stringWriter.toString(); |
String | getStackTraceAsText(Throwable t) get Stack Trace As Text ByteArrayOutputStream exceptionTraceText = new ByteArrayOutputStream(); PrintStream exceptionTrace = new PrintStream(exceptionTraceText); t.printStackTrace(exceptionTrace); return exceptionTraceText.toString(); |
String | getStackTraceFromBaseException(Throwable exc) get Stack Trace From Base Exception String str = ""; try { Exception be = (Exception) exc; java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos, false, "UTF8"); be.printStackTrace(ps); str = baos.toString("UTF8"); } catch (Exception e) { ... |
String | getStackTraceFromThrowable(Throwable t) get Stack Trace From Throwable StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); t.printStackTrace(pw); pw.println(); if (t.getCause() != null) { t.getCause().printStackTrace(pw); return sw.toString(); ... |
String | getStackTraceInString(Throwable throwable) get Stack Trace In String ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); PrintStream printStream = new PrintStream(byteArrayOutputStream); throwable.printStackTrace(printStream); printStream.flush(); return byteArrayOutputStream.toString(); |