Here you can find the source of deleteDirectory(File directory, boolean ignoreErrors)
public static boolean deleteDirectory(File directory, boolean ignoreErrors)
//package com.java2s; //License from project: Open Source License import java.io.File; public class Main { public static boolean deleteDirectory(File directory, boolean ignoreErrors) { try {//from ww w. ja v a 2s.c o m if (directory.exists() && directory.isDirectory()) { File files[] = directory.listFiles(); for (File file : files) { if (file.isDirectory()) { deleteDirectory(file, true); } else { file.delete(); } } } } catch (Exception ex) { if (!ignoreErrors) ex.printStackTrace(); } return (directory.delete()); } }