- Timestamp:
- 10/10/11 22:15:34 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaHelperLib/src/de/ugoe/cs/util/console/FileOutputListener.java
r243 r250 39 39 * </p> 40 40 */ 41 FileWriter writer ;41 FileWriter writer = null; 42 42 43 43 /** … … 78 78 public void stop() { 79 79 Console.getInstance().removeOutputListener(this); 80 try { 81 writer.close(); 82 } catch (IOException e) { 83 Console.printerrln("Failed to close file " + filename + ": " 84 + e.getMessage()); 80 if( writer!=null ) { 81 try { 82 writer.close(); 83 writer = null; 84 } catch (IOException e) { 85 Console.printerrln("Failed to close file " + filename + ": " 86 + e.getMessage()); 87 } 85 88 } 86 89 } … … 95 98 @Override 96 99 public void outputMsg(String newMessage) { 97 try { 98 writer.write(newMessage); 99 } catch (IOException e) { 100 if (!failureLogged) { 101 Console.printerrln("FileOutpustListener for file " + filename 102 + " broken: " + e.getMessage()); 103 failureLogged = true; 100 if( writer!=null ) { 101 try { 102 writer.write(newMessage); 103 } catch (IOException e) { 104 if (!failureLogged) { 105 Console.printerrln("FileOutpustListener for file " + filename 106 + " broken: " + e.getMessage()); 107 failureLogged = true; 108 } 104 109 } 105 110 } 106 111 } 107 112 113 /** 114 * <p> 115 * Returns the name of the log file used by this listener. 116 * </p> 117 * 118 * @return name of the log file 119 */ 120 public String getFilename() { 121 return filename; 122 } 123 108 124 }
Note: See TracChangeset
for help on using the changeset viewer.