This method will delete any files and empty directories provided in the fileList. It seems to be working. I use recursion to delete the empty directories and i'm worried about cases that will create an infinite loop. Any thoughts or things to consider with this approach?
public static void deleteFilesAndEmptyDirs(List<File> fileList) {
boolean result = true;
List<File> returnList = new LinkedList<File>();
for (File file : fileList) {
result = file.delete();
if(result == false && file.isDirectory()) {
returnList.add(file);
}
}
if(returnList.size() >= 1) {
deleteFilesAndEmptyDirs(returnList);
}
}