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

voidprintStackTrace(Throwable t)
print Stack Trace
serr();
t.printStackTrace();
Stringserialize(Throwable t)
serialize
StringWriter errors = new StringWriter();
t.printStackTrace(new PrintWriter(errors));
return errors.toString();
StringserializeStackTrace(Throwable _t)
Serialize stack trace.
java.io.ByteArrayOutputStream byteArrayOutputStream = new java.io.ByteArrayOutputStream();
java.io.PrintWriter printWriter = null;
String errorString = null;
try {
    printWriter = new java.io.PrintWriter(byteArrayOutputStream, true);
    _t.printStackTrace(printWriter);
    errorString = byteArrayOutputStream.toString();
} catch (Throwable u) {
...
StringserializeStackTrace(Throwable th)
Gets a string representation of a stack trace.
ByteArrayOutputStream bout = new ByteArrayOutputStream();
PrintWriter pw = new PrintWriter(bout);
th.printStackTrace(pw);
pw.close();
return bout.toString();
StringstackToString(Exception e)
stack To String
try {
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    e.printStackTrace(pw);
    return "------\n" + sw.toString() + "------\n";
} catch (Exception e2) {
    return "bad stackToString";
StringstackToString(Throwable e)
Get a string containing the stack of the specified exception
java.io.StringWriter sw = new java.io.StringWriter();
java.io.BufferedWriter bw = new java.io.BufferedWriter(sw);
java.io.PrintWriter pw = new java.io.PrintWriter(bw);
e.printStackTrace(pw);
pw.close();
return sw.getBuffer().toString();
StringstackToString(Throwable e)
Get a string containing the stack of the specified exception
java.io.StringWriter sw = new java.io.StringWriter();
java.io.BufferedWriter bw = new java.io.BufferedWriter(sw);
java.io.PrintWriter pw = new java.io.PrintWriter(bw);
e.printStackTrace(pw);
pw.close();
String text = sw.getBuffer().toString();
text = text.substring(text.indexOf("at"));
text = replace(text, "at ", "DEBUG_FRAME = ");
...
StringstackToString(Throwable e)
stack To String
java.io.StringWriter sw = new java.io.StringWriter(1024);
java.io.PrintWriter pw = new java.io.PrintWriter(sw);
e.printStackTrace(pw);
pw.close();
return sw.toString();
StringstackToString(Throwable t)
Writes a throwed exception to a string for streaming to the server
Writer result = new StringWriter();
PrintWriter printWriter = new PrintWriter(result);
t.printStackTrace(printWriter);
return result.toString();
StringBufferstackToString(Throwable throwable, boolean skipMessage)
Dump message and stack to StringBuffer.
if (null == throwable) {
    return new StringBuffer();
StringWriter buf = new StringWriter();
PrintWriter writer = new PrintWriter(buf);
if (!skipMessage) {
    writer.println(throwable.getMessage());
throwable.printStackTrace(writer);
try {
    buf.close();
} catch (IOException ioe) {
return buf.getBuffer();