public class MyUtils {
/**
* Exception转String
* @param e
* @return
*/
public String ExceptionToString(Exception e) {
try {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
sw.close(); // 可以不用关闭
pw.close();
return "\r\n" + sw.toString() + "\r\n";
} catch (Exception e2) {
return "ErrorInfoFromException";
}
}
}