Created
February 1, 2013 02:30
-
-
Save bluerabbit/4688711 to your computer and use it in GitHub Desktop.
ExceptionのStackTraceを文字列で取得する
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 static String getStackTrace(Throwable e) { | |
| StringWriter sw = null; | |
| PrintWriter pw = null; | |
| try { | |
| sw = new StringWriter(); | |
| pw = new PrintWriter(sw); | |
| e.printStackTrace(pw); | |
| return sw.toString(); | |
| } finally { | |
| try { | |
| if (sw != null) { | |
| sw.flush(); | |
| sw.close(); | |
| } | |
| if (pw != null) { | |
| pw.flush(); | |
| pw.close(); | |
| } | |
| } catch (IOException ignore) { | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment