Here you can find the source of deleteDir(File dir)
public static boolean deleteDir(File dir)
//package com.java2s; import java.io.*; public class Main { public static boolean deleteDir(File dir) { if (dir.isDirectory()) { String[] children = dir.list(); for (String child : children) { boolean success = deleteDir(new File(dir, child)); if (!success) { return false; }//from w w w. j a v a 2 s . com } } return dir.delete(); } }