Skip to content

Instantly share code, notes, and snippets.

@sourcerebels
Created March 1, 2010 13:17
Show Gist options
  • Save sourcerebels/318366 to your computer and use it in GitHub Desktop.
Save sourcerebels/318366 to your computer and use it in GitHub Desktop.
exception2String Print exception's stack trace to a string
/**
* Transforms a Exception stack trace into String.
* @param e The exception to be transformed.
* @return A string with the stack trace text.
*/
public String exception2String(Exception e) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
return pw.toString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment