Here you can find the source of deleteDirectory(File path, boolean includeDir)
static public boolean deleteDirectory(File path, boolean includeDir)
//package com.java2s; //License from project: Apache License import java.io.File; public class Main { static public boolean deleteDirectory(File path, boolean includeDir) { boolean success = true; if (path.exists()) { File[] files = path.listFiles(); for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) { success = deleteDirectory(files[i], true) && success; } else { success = files[i].delete() && success; }//from w w w .j a v a 2s.c o m } } if (includeDir) success = path.delete() && success; return success; } }