`
fei_6666
  • 浏览: 203889 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

将java异常信息stackTrace转换成字符串

阅读更多

public static void main(String[] args) {

List l = new ArrayList();
try {
l.get(9);
} catch (Exception e) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);

System.out.println(sw.toString()); // stack trace as a string
    e.printStackTrace();


}
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics