How do I delete a directory that isn't empty?
Created May 7, 2012
Christopher Schultz It's got to be a recursive-like method (in that it recurses the subdirs and deletes their contents, too). Something like this will probably work (off the top of my head):
import java.io.File;
.
.
.
public void nuke(File path)
throws IOException
{
File[] files = path.listFiles();
for(int i=0; i<files.length; ++i)
{
if(files[i].isDirectory())
nuke(files[i]);
files[i].delete();
}
}
You may want to do some more error checking, etc. but that should basically work.