Here you can find the source of deleteDir(File dir)
public static final void deleteDir(File dir)
//package com.java2s; // License: GPL. For details, see LICENSE file. import java.io.File; public class Main { public static final void deleteDir(File dir) { for (File file : dir.listFiles()) { if (!file.delete()) { file.deleteOnExit();// ww w . j a va 2 s . c o m } } if (!dir.delete()) { dir.deleteOnExit(); } } }