Created
March 8, 2010 20:14
-
-
Save programaker/325577 to your computer and use it in GitHub Desktop.
How to get the stack trace of an exception as 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
| public String getStackTrace(Exception e) { | |
| Writer stringWriter = new StringWriter(); | |
| PrintWriter printWriter = new PrintWriter(stringWriter); | |
| e.printStackTrace(printWriter); | |
| return stringWriter.toString(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment