具体点说,我现在出现了一个异常,printStackTrace()它之后,控制台里打印出:
java.sql.SQLException: Duplicate entry 'http://topic.csdn.net/u/20080722/21/25c6beb6-0aa3-460e-bec5-ab3e' for key 2
at test.htmlparser.ReadHtml.main(ReadHtml.java:37)
而我尝试着在SQLException e这个对象中获取上面这一长串字符串,失败了,最多只能获得下面这行字符串:
java.sql.SQLException: Duplicate entry 'http://topic.csdn.net/u/20080722/21/25c6beb6-0aa3-460e-bec5-ab3e' for key 2因此,最最重要的"at test.htmlparser.ReadHtml.main(ReadHtml.java:37)"获取不了,怎么样才能在程序中获取呢?
java.sql.SQLException: Duplicate entry 'http://topic.csdn.net/u/20080722/21/25c6beb6-0aa3-460e-bec5-ab3e' for key 2
at test.htmlparser.ReadHtml.main(ReadHtml.java:37)
而我尝试着在SQLException e这个对象中获取上面这一长串字符串,失败了,最多只能获得下面这行字符串:
java.sql.SQLException: Duplicate entry 'http://topic.csdn.net/u/20080722/21/25c6beb6-0aa3-460e-bec5-ab3e' for key 2因此,最最重要的"at test.htmlparser.ReadHtml.main(ReadHtml.java:37)"获取不了,怎么样才能在程序中获取呢?
System.out.println(ste);
}
其中的printStackTrace(PrintStream ps)和printStackTrace(PrintWriter pw)方法都可以完成LZ的需求
LZ只需要创建自己的PrintStream类或者PrintWriter类,覆盖里面的相应方法,就可以得到堆栈的内容了。
LZ还可以对这些内容进行过滤,只保留需要的部分。
这个比较靠谱,可是能告诉我具体实现步骤吗?3q3q~~