Here you can find the source of deleteFolderRecursively(File file)
public static void deleteFolderRecursively(File file)
//package com.java2s; //License from project: LGPL import java.io.File; public class Main { public static void deleteFolderRecursively(File file) { try {//from ww w.j av a 2s . com File[] allFiles = file.listFiles(); if (allFiles == null) { file.delete(); return; } for (File f : allFiles) { if (f.isDirectory()) deleteFolderRecursively(f); else f.delete(); } file.delete(); // Make sure to delete the folder once we've cleared out its contents } catch (Exception e) { e.printStackTrace(); } } }