Mercurial Hosting > luan
comparison src/goodjava/lucene/logging/LoggingIndexWriter.java @ 1475:c7b86342857f
more IoUtils
| author | Franklin Schmidt <fschmidt@gmail.com> | 
|---|---|
| date | Sat, 18 Apr 2020 11:02:18 -0600 | 
| parents | 6c6ce14db6a8 | 
| children | 7d145095cc0b | 
   comparison
  equal
  deleted
  inserted
  replaced
| 1474:13cbce740e1e | 1475:c7b86342857f | 
|---|---|
| 121 for( LogFile lf : logs ) { | 121 for( LogFile lf : logs ) { | 
| 122 used.add( lf.file.getName() ); | 122 used.add( lf.file.getName() ); | 
| 123 } | 123 } | 
| 124 for( File f : logDir.listFiles() ) { | 124 for( File f : logDir.listFiles() ) { | 
| 125 if( !used.contains(f.getName()) ) { | 125 if( !used.contains(f.getName()) ) { | 
| 126 deleteFile(f); | 126 IoUtils.deleteRecursively(f); | 
| 127 } | 127 } | 
| 128 } | 128 } | 
| 129 } | |
| 130 | |
| 131 private static void deleteFile(File file) throws IOException { | |
| 132 if( file.isDirectory() ) { | |
| 133 for( File f : file.listFiles() ) { | |
| 134 deleteFile(f); | |
| 135 } | |
| 136 } | |
| 137 IoUtils.delete(file); | |
| 138 } | 129 } | 
| 139 | 130 | 
| 140 private void writeIndex() throws IOException { | 131 private void writeIndex() throws IOException { | 
| 141 ByteArrayOutputStream baos = new ByteArrayOutputStream(); | 132 ByteArrayOutputStream baos = new ByteArrayOutputStream(); | 
| 142 DataOutputStream dos = new DataOutputStream(baos); | 133 DataOutputStream dos = new DataOutputStream(baos); | 
| 216 System.out.println("checkWriter"); | 207 System.out.println("checkWriter"); | 
| 217 dump(checkWriter); | 208 dump(checkWriter); | 
| 218 System.exit(-1); | 209 System.exit(-1); | 
| 219 } | 210 } | 
| 220 checkWriter.close(); | 211 checkWriter.close(); | 
| 221 deleteFile(dirFile); | 212 IoUtils.deleteRecursively(dirFile); | 
| 222 } | 213 } | 
| 223 | 214 | 
| 224 private LogFile log() { | 215 private LogFile log() { | 
| 225 return logs.get(logs.size()-1); | 216 return logs.get(logs.size()-1); | 
| 226 } | 217 } | 
