Here you can find the source of deleteDir(File dir)
public static boolean deleteDir(File dir)
//package com.java2s; import java.io.File; public class Main { public static boolean deleteDir(File dir) { if (dir.isDirectory()) { File[] children = dir.listFiles(); for (File child : children) { boolean success = deleteDir(child); if (!success) { return false; }//w ww . j av a 2 s. c o m } } // The directory is now empty so delete it return dir.delete(); } }