Created
October 31, 2013 04:49
-
-
Save azusa/7244493 to your computer and use it in GitHub Desktop.
Javaの例外を文字列にする
This file contains 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
package jp.fieldnotes.gist; | |
import java.io.PrintWriter; | |
import java.io.StringWriter; | |
public class WriteException { | |
public static String toString(Throwable t) { | |
StringWriter sw = new StringWriter(); | |
try (PrintWriter pw = new PrintWriter(sw)) { | |
t.printStackTrace(pw); | |
return sw.toString(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment