Created
March 1, 2010 13:17
-
-
Save sourcerebels/318366 to your computer and use it in GitHub Desktop.
exception2String Print exception's stack trace to a string
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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