|
The other day I was asked "How do I delete a directory tree with Java?"
The delete method of the File class won't delete a directory tree, meaning that in the old days you had to write your own recursive method to do this.
But fortunately today you can just use a static method in the FileUtils class of the Jakarta Commons IO project, like this:
FileUtils.delete("/Users/al/old-directory");
As you might guess, this deletes the directory named old-directory in my home directory (/Users/al).
Just download the Commons IO library and include it in your project, and you're ready to go.
|