Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (3.9k points)
Is there a way to delete entire directories recursively in Java?

In the normal case, it is possible to delete an empty directory. However, when it comes to deleting entire directories with contents, it is not that simple anymore.

How do you delete entire directories with contents in Java?

1 Answer

0 votes
by (46k points)

You should verify out Apache's commons-io. It possesses a FileUtils class that will do what you require.

FileUtils.deleteDirectory(new File("directory"));

Related questions

0 votes
1 answer
asked Oct 13, 2019 in Java by Ritik (3.5k points)
0 votes
1 answer
asked Sep 29, 2019 in Java by Shubham (3.9k points)
0 votes
1 answer
asked Nov 12, 2019 in Java by Anvi (10.2k points)
0 votes
1 answer
asked Oct 29, 2019 in Java by Anvi (10.2k points)

Browse Categories

...