Created
October 17, 2019 15:52
-
-
Save team172011/ae9c9a3da3c21cc515b27b136a67c2ec to your computer and use it in GitHub Desktop.
Delete a folder in java
This file contains 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 deleteDirRecursive(File folder) { | |
File[] files = folder.listFiles(); | |
if (files != null) { | |
for (File f : files) { | |
if (f.isDirectory()) { | |
deleteDirRecursive(f); | |
} else { | |
f.delete(); | |
} | |
} | |
} | |
folder.delete() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment