Here you can find the source of deleteDirectory(File dir, boolean isInitialDelete)
public static boolean deleteDirectory(File dir, boolean isInitialDelete)
//package com.java2s; //License from project: Open Source License import java.io.File; public class Main { public static boolean deleteDirectory(File dir, boolean isInitialDelete) { if (dir.isDirectory()) { if (dir.exists()) { for (File child : dir.listFiles()) { try { deleteDirectory(child, isInitialDelete); } catch (Exception e) { if (isInitialDelete) continue; else return false; }// ww w . j a v a 2 s .c o m } } } dir.delete(); return true; } public static boolean isDirectory(File f) { if (f != null && f.exists() && f.isDirectory()) { return true; } return false; } }