Here you can find the source of deleteDir(File dir)
private static boolean deleteDir(File dir)
//package com.java2s; //License from project: LGPL import java.io.File; public class Main { private static boolean deleteDir(File dir) { if (dir.isDirectory()) { String[] children = dir.list(); for (int i = 0; i < children.length; i++) { boolean success = deleteDir(new File(dir, children[i])); if (!success) { return false; }/* w ww. ja v a 2s . com*/ } } // The directory is now empty so delete it return dir.delete(); } public static void delete(String path) { if (!deleteDir(new File(path))) { throw new RuntimeException("Directory was not removed"); } } }