Here you can find the source of deleteDirectory(String dirName)
public static boolean deleteDirectory(String dirName)
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { public static boolean deleteDirectory(String dirName) { return deleteDirectory(new File(dirName)); }//from w w w. j a v a 2s. c o m public static boolean deleteDirectory(File dir) { if ((dir == null) || !dir.isDirectory()) { throw new IllegalArgumentException("Argument " + dir + " is not a directory. "); } File[] entries = dir.listFiles(); int sz = entries != null ? entries.length : 0; for (File entry : entries != null ? entries : new File[0]) { if (entry.isDirectory()) { if (!deleteDirectory(entry)) { return false; } } else { if (!entry.delete()) { return false; } } } return dir.delete(); } }