(Path dir)
| 9 | |
| 10 | public class RmDir { |
| 11 | public static void rmdir(Path dir) |
| 12 | throws IOException { |
| 13 | Files.walkFileTree(dir, |
| 14 | new SimpleFileVisitor<Path>() { |
| 15 | @Override public FileVisitResult |
| 16 | visitFile(Path file, BasicFileAttributes attrs) |
| 17 | throws IOException { |
| 18 | Files.delete(file); |
| 19 | return FileVisitResult.CONTINUE; |
| 20 | } |
| 21 | @Override public FileVisitResult |
| 22 | postVisitDirectory(Path dir, IOException exc) |
| 23 | throws IOException { |
| 24 | Files.delete(dir); |
| 25 | return FileVisitResult.CONTINUE; |
| 26 | } |
| 27 | }); |
| 28 | } |
| 29 | } |