Here you can find the source of deleteDir(File path)
public static boolean deleteDir(File path)
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { public static boolean deleteDir(File path) { if (path.exists()) { File[] files = path.listFiles(); for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) { deleteDir(files[i]); } else { files[i].delete();// w w w .j a v a 2 s .c o m } } } boolean ok = path.delete(); if (!ok) System.err.println("[WARN] Unable to delete: " + path); return ok; } }