1boolean deleteDirectory(File directoryToBeDeleted) {
2 File[] allContents = directoryToBeDeleted.listFiles();
3 if (allContents != null) {
4 for (File file : allContents) {
5 deleteDirectory(file);
6 }
7 }
8 return directoryToBeDeleted.delete();
9}
1String[]entries = index.list();
2for(String s: entries){
3 File currentFile = new File(index.getPath(),s);
4 currentFile.delete();
5}