Here you can find the source of deleteDir(File dirFile)
public static boolean deleteDir(File dirFile)
//package com.java2s; //License from project: Apache License import java.io.File; public class Main { public static boolean deleteDir(File dirFile) { if (!dirFile.exists()) { return false; }//from w ww . j a v a 2s. c om if (dirFile.isFile()) { return dirFile.delete(); } else { File[] files = dirFile.listFiles(); if (files == null || files.length == 0) { return dirFile.delete(); } for (File file : files) { deleteDir(file); } } return dirFile.delete(); } }