StringWriter 接收异常信息

try {
int a=1/0;
} catch (Exception e) {
StringWriter sw = new StringWriter();
e.printStackTrace(new PrintWriter(sw, true));
System.out.println("e.message:"+e.getMessage());
System.out.println("e.printstack~~~~~:"+sw.toString());
}

你可能感兴趣的:(JAVA)