Here you can find the source of deleteDirectory(File file)
public static boolean deleteDirectory(File file)
//package com.java2s; import java.io.File; public class Main { public static boolean deleteDirectory(File file) { File[] list = file.listFiles(); boolean done = true; for (File f : list) { done &= deleteFile(f);// ww w .ja v a 2 s . c o m } return done; } public static boolean deleteDirectory(String file) { return deleteDirectory(new File(file)); } public static boolean deleteFile(File file) { if (file.isDirectory()) { return deleteDirectory(file); } else { return file.delete(); } } public static boolean deleteFile(String file) { return deleteFile(new File(file)); } }