Here you can find the source of deleteDir(File dir)
static void deleteDir(File dir)
//package com.java2s; //License from project: Apache License import java.io.File; public class Main { static void deleteDir(File dir) { if (!dir.exists()) { return; }/* w w w . ja va 2 s .c om*/ for (File e : dir.listFiles()) { if (e.isDirectory()) deleteDir(e); else delete(e); } delete(dir); } static void delete(File f) { boolean success = f.delete(); String path = f.getAbsolutePath(); if (success) { System.out.println("delete file : " + path); } else { throw new IllegalStateException("deleting file failed. " + path); } } }