Skip to content

Instantly share code, notes, and snippets.

@ram0973
Created January 31, 2021 11:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ram0973/56304eeaea63626acbff5dd1f6edc3e8 to your computer and use it in GitHub Desktop.
Save ram0973/56304eeaea63626acbff5dd1f6edc3e8 to your computer and use it in GitHub Desktop.
deleteDirRecursively in Java
public void deleteDirRecursively(File dir) {
File[] children = dir.listFiles();
for (File child : children) {
if (child.isDirectory()) {
deleteDirRecursively(child);
} else {
child.delete();
}
}
dir.delete();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment