// taken before the 300 characters, to avoid exceeding the length of the database field when the abnormality information stored in the database public static String GeTe (Exception E) { String S = getStackTraceInfo (E); IF (s.length ()> = 300 ) { return s.substring (0, 300 ); } return S; } / ** * Get e.printStackTrace () of the specific information is assigned to a String variable, and returns * * @param E * Exception * @return e.printStackTrace ( information) in * / public static String getStackTraceInfo (Exception E) { SW the StringWriter = null ; the PrintWriter PW = null ; the try { SW = new new the StringWriter (); PW = new new the PrintWriter (SW); e.printStackTrace (PW); // The error information is output to the stack in printWriter pw.flush () ; sw.flush (); return sw.toString (); } the catch (Exception EX) { return "error" ; } the finally { IF ! (SW = null) { try { sw.close(); } catch (IOException e1) { e1.printStackTrace(); } } if (pw != null) { pw.close(); } } }