Here you can find the source of deleteDirectory(String path)
public static int deleteDirectory(String path)
//package com.java2s; //License from project: Open Source License import java.io.File; public class Main { public static int deleteDirectory(String path) { File dir = new File(path); if (!dir.exists() || !dir.isDirectory()) return 4; if (deleteStuffRecursive(dir)) { return 0; }//from ww w . ja v a 2 s .c om return 1; } private static boolean deleteStuffRecursive(File item) { if (item.exists()) { if (item.isDirectory()) { for (File child : item.listFiles()) { if (!deleteStuffRecursive(child)) { return false; } } } return item.delete(); } return false; } }