Java Utililty Methods Throwable to String

List of utility methods to do Throwable to String

Description

The list of methods to do Throwable to String are organized into topic(s).

Method

StringgetStackTrace(Throwable e)
Gets a stack trace for an exception.
ByteArrayOutputStream traceByteArrayStream = new ByteArrayOutputStream();
PrintStream tracePrintStream = new PrintStream(traceByteArrayStream);
e.printStackTrace(tracePrintStream);
tracePrintStream.flush();
return traceByteArrayStream.toString();
StringgetStackTrace(Throwable ex)
Get exception stack trace.
String result = "";
try {
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    ex.printStackTrace(pw);
    pw.close();
    sw.close();
    result = sw.toString();
...
StringTokenizergetStackTrace(Throwable ex)
get Stack Trace
ByteArrayOutputStream temp = new ByteArrayOutputStream();
ex.printStackTrace(new PrintStream(temp));
String stackTrace = new String(temp.toByteArray());
return new StringTokenizer(stackTrace, LINE_BREAKING);
StringgetStackTrace(Throwable ex)
get Stack Trace
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw, true);
pw.write("\n---------------------- EXCEPTION STACK TRACE ----------------------\n");
ex.printStackTrace(pw);
if (ex.getCause() != null) {
    pw.write("\n---------------------- CAUSE EXCEPTION STACK TRACE ----------------------\n");
    ex.getCause().printStackTrace(pw);
    pw.write("\n---------------------- CAUSE EXCEPTION STACK TRACE ----------------------\n");
...
String[]getStackTrace(Throwable exc)
Creates and array of strings containing the exception traceback information of a Throwable.
Vector lines = new Vector();
StringWriter stringWriter = new StringWriter();
PrintWriter printWriter = new PrintWriter(stringWriter);
exc.printStackTrace(printWriter);
try {
    printWriter.close();
    stringWriter.close();
} catch (Exception nestedExc) {
...
StringgetStackTrace(Throwable exception)
get Stack Trace
StringWriter sw = null;
PrintWriter pw = null;
try {
    sw = new StringWriter();
    pw = new PrintWriter(sw);
    exception.printStackTrace(pw);
    return sw.toString();
} finally {
...
StringgetStackTrace(Throwable exception)
Gibt den StackTrace der Exception als String zurueck.
String result = null;
if (exception != null) {
    StringWriter stringWriter = new StringWriter();
    PrintWriter printWriter = new PrintWriter(stringWriter);
    exception.printStackTrace(printWriter);
    printWriter.flush();
    result = stringWriter.toString();
return result;
StringgetStackTrace(Throwable pException)
this method returns a String representation of an Exception's stacktrace
ByteArrayOutputStream bos = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(bos);
pException.printStackTrace(ps);
ps.flush();
return bos.toString();
StringgetStackTrace(Throwable pThrowable_)
Returns a string which contains the stack trace.
StringWriter pStringWriter = new StringWriter();
PrintWriter pPrintWriter = new PrintWriter(pStringWriter);
pThrowable_.printStackTrace(pPrintWriter);
return pStringWriter.toString();
StringgetStackTrace(Throwable t)
Get the full stacktrace as a string
Writer result = new StringWriter();
PrintWriter writer = new PrintWriter(result);
t.printStackTrace(writer);
try {
    writer.flush();
    result.flush();
    writer.close();
    result.close();
...