파일 하위포함 삭제

java 2015. 12. 14. 13:38

//하위 디렉토리 및 파일 삭제

Files.walkFileTree(f.toPath(), new SimpleFileVisitor<Path>() {

@Override

public FileVisitResult postVisitDirectory(Path dir,

IOException exc) throws IOException {

Files.delete(dir);

return FileVisitResult.CONTINUE;

}

@Override

public FileVisitResult visitFile(Path file,

BasicFileAttributes attrs) throws IOException {

Files.delete(file);

return FileVisitResult.CONTINUE;

}

});

Posted by 우주정복☆
,