tips/JAVA/Throwable printStackTrace() の結果を文字列として取り出す(追記) のバックアップ(No.1)
- バックアップ一覧
- 差分 を表示
- 現在との差分 を表示
- ソース を表示
- tips/JAVA/Throwable printStackTrace() の結果を文字列として取り出す(追記) へ行く。
- 1 (2008-03-13 (木) 01:55:19)
tips/JAVA/Throwable printStackTrace() の結果を文字列として取り出す(2 of 2)
Throwable printStackTrace() の結果を文字列として取り出す(追記) †
以前書いた
tips/JAVA/Throwable printStackTrace() の結果を文字列として取り出す(1 of 2)
tips/JAVA/Throwable printStackTrace() の結果を文字列として取り出す(2 of 2)
について、PipedReader/Writer を用いて実現しようとしていましたが、 もっと簡便な方法がありました。。。
Throwable#printStackTrace(PrintWriter) の引数に渡す PrintWriter に StringWriter を使えばよいようです。 StringWriter なんて便利なクラスがあったんですね。。。
ちなみにマルチスレッドでの挙動は確認していません。