The code is as follows:
| < Pre class= "Brush:java; Auto-links:true; Collapse:false; First-line:1; Gutter:true; Html-script:false; Light:false; Ruler:false; Smart-tabs:true; Tab-size:4; Toolbar:true; " >try{******} catch (Exception ex) {try {File file = new file ("E:/log.txt"); PrintWriter writer = null; FileWriter fileWrite = new FileWriter (string.valueof (file), true); writer = new PrintWriter (fileWrite); Writer.append (System.getproperty ("Line.separator") + new SimpleDateFormat ("Yyyy-mm-dd:hh:mm:ss"). Format (new Date () )); Writer.append (System.getproperty ("Line.separator")); Writer.append ("*************************" + ex.tostring () + "*************************"); Writer.append (System.getproperty ("Line.separator")); Ex.printstacktrace (writer); Writer.flush (); Writer.close (); } catch (IOException e) {e.printstacktrace (); }} |
Java writes exceptions to txt text