After enumerating a directory, I now need to delete all the files.
I used:
final File[] files = outputFolder.listFiles();
files.delete();
But this hasn't deleted the directory.
After enumerating a directory, I now need to delete all the files.
I used:
final File[] files = outputFolder.listFiles();
files.delete();
But this hasn't deleted the directory.
Here is one possible solution to solve the problem without a library :
public static boolean delete(File file) {
File[] flist = null;
if(file == null){
return false;
}
if (file.isFile()) {
return file.delete();
}
if (!file.isDirectory()) {
return false;
}
flist = file.listFiles();
if (flist != null && flist.length > 0) {
for (File f : flist) {
if (!delete(f)) {
return false;
}
}
}
return file.delete();
}
You have to do this for each File:
Then call