Here you can find the source of deleteDir(File dir, boolean deleteSelf)
public static boolean deleteDir(File dir, boolean deleteSelf)
//package com.java2s; // Licensed under the Apache License, Version 2.0 (the "License"); import java.io.File; public class Main { public static boolean deleteDir(String dir) { return deleteDir(new File(dir), true); }// w w w .j a va 2 s .c om public static boolean deleteDir(File dir, boolean deleteSelf) { if (dir.isDirectory()) { String[] children = dir.list(); for (String child : children) { boolean success = deleteDir(new File(dir, child), true); if (!success) { return false; } } } if (deleteSelf) { return dir.delete(); } else { return true; } } }