Created
August 28, 2019 13:03
-
-
Save thekalinga/079b0ef4c5b6665fcf710eab0b5c61c4 to your computer and use it in GitHub Desktop.
Delete directory recursively in java8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void deleteDirRecursively(Path pathToDel) throws IOException { | |
Files.walk(pathToDel) | |
.sorted(reverseOrder()) // dir would be listed before the files inside. So, we delete the files in the right order | |
.forEach(path -> run(() -> delete(path))); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment