将异常栈信息打印到日志文件中。
//返回该异常的 String类型异常栈信息
public static String exStack2Str(Exception e) {
StringWriter sw=null;//字符流不用关闭
PrintWriter pw=null;
try {
sw = new StringWriter();
pw = new PrintWriter(sw);
e.printStackTrace(pw);
} catch (Exception e1) {
return e1.getMessage();
}finally{
if(pw!=null)
pw.close();
}
return sw.toString();
}