Here you can find the source of delTree(File dir, boolean deleteDirItSelf)
public static void delTree(File dir, boolean deleteDirItSelf)
//package com.java2s; import java.io.File; public class Main { /**/* w w w.j a v a 2 s. c o m*/ * * File management utilities * */ public static void delTree(File dir, boolean deleteDirItSelf) { if (!dir.exists()) return; for (File subFile : dir.listFiles()) { // String name = subFile.getName(); if (subFile.isDirectory()) { delTree(subFile, true); } subFile.delete(); } if (deleteDirItSelf) { dir.delete(); } } }