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();
}
}