Skip to content

Instantly share code, notes, and snippets.

@team172011
Created October 17, 2019 15:52
Show Gist options
  • Save team172011/ae9c9a3da3c21cc515b27b136a67c2ec to your computer and use it in GitHub Desktop.
Save team172011/ae9c9a3da3c21cc515b27b136a67c2ec to your computer and use it in GitHub Desktop.
Delete a folder in java
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