Convert Exception to String output in java
First, the code is implemented as follows:
/** * Convert Exception to String */ public static String getExceptionToString(Throwable e) { if (e == null){ return ""; } StringWriter stringWriter = new StringWriter(); e.printStackTrace(new PrintWriter(stringWriter)); return stringWriter.toString(); }
Supplementary information:
Detailed study of java exception: http://www.cnblogs.com/Qian123/p/5715402.html