Skip to content

Instantly share code, notes, and snippets.

@azusa
Created October 31, 2013 04:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save azusa/7244493 to your computer and use it in GitHub Desktop.
Save azusa/7244493 to your computer and use it in GitHub Desktop.
Javaの例外を文字列にする
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