LoginSignup
62
52

More than 5 years have passed since last update.

Javaの例外のスタックトレースをStringに変換するスニペット

Posted at

これまたよく使う。

// エラーのスタックトレースを表示
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
pw.flush();
String str = sw.toString();
62
52
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
62
52