I am currently trying to recursively delete a directory... Strangely enough the shortest piece of code I was able to find is the following construct, employing an ad-hoc
The following solution doesn't need the conversion from Path to File objects:
Path rootPath = Paths.get("/data/to-delete"); final List pathsToDelete = Files.walk(rootPath).sorted(Comparator.reverseOrder()).collect(Collectors.toList()); for(Path path : pathsToDelete) { Files.deleteIfExists(path); }