症状は簡単です:Windowsは、内容がまだ存在すると考えているため、Windowsを拒否します。ただし、再帰的な削除によって削除されただけです。だから、私の最初の推測では、コンテンツを削除して削除する前に、親ディレクトリにflush/syncまたは同様の行方不明があるということです。信頼できる再帰的なディレクトリの削除はできませんか?
私はコモンズ-ioのバージョン2.5 FileUtils.deleteDirectoryとFileUtils.cleanDirectory機能だけでなく、私自身の簡素化テストを試してみました:
@Test
public void testMySimpleDelete() throws IOException, InterruptedException {
File dir = TEST_DIR;
for (int i = 0; i < 10; i++) {
dir = new File(dir, Integer.toString(i));
}
for (int i = 0; i < 1000; i++) {
LOG.info(""+i);
assertTrue("loop #" + i, dir.mkdirs());
mySimpleDelete(Paths.get(TEST_DIR.getAbsolutePath()));
assertFalse(TEST_DIR.exists());
}
}
private void mySimpleDelete(Path file) throws IOException, InterruptedException {
Files.walkFileTree(file, new FileVisitor<Path>() {
@Override
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
return FileVisitResult.CONTINUE;
}
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
//LOG.info(dir.toString());
Files.delete(dir);
return FileVisitResult.CONTINUE;
}
});
}
すべてが同じ結果/症状を示します。
あなた自身のため、この動作を確認したい場合は(Windows上でのみ!Linuxは、すべてで何かをロックし、道より寛大なように動作していない)、単にhttps://github.com/jjYBdx4IL/java-evaluationをチェックアウトして、「MVNテストを実行-Dtest = org.apache .commons.io.FileUtilsTest "を参照してください。
も参照してくださいhttp://stackoverflow.com/q/22948189/886887 –