コード例 #1
0
 public void markForDeletion(File file) {
   TempFile tempFile = deleteMap.get(file.getPath());
   if (tempFile != null) {
     deleteQueue.remove(tempFile);
     deleteMap.remove(tempFile);
   } else {
     tempFile = new TempFile(file);
     deleteQueue.add(new TempFile(file));
     deleteMap.put(tempFile.getFile().getPath(), tempFile);
     file.deleteOnExit(); // just in case
   }
 }
コード例 #2
0
 public void run() {
   Thread.currentThread().setName("deleteHelper");
   if (deleteQueue.size() > 0) {
     TempFile temp = deleteQueue.peek();
     if (temp != null && temp.getOld()) {
       logger.debug(
           "removing temporary file {tempfile='" + temp.getFile().getAbsolutePath() + "'}");
       deleteQueue.poll();
       deleteMap.remove(temp);
       try {
         temp.getFile().delete();
       } catch (Exception e) {
       }
     }
   }
 }