Here you can find the source of recursiveDelete(final File root, final File file)
private static void recursiveDelete(final File root, final File file)
//package com.java2s; //License from project: BSD License import java.io.File; public class Main { private static void recursiveDelete(final File root, final File file) { if (!file.isDirectory()) { file.delete();// w w w.j av a 2 s .c o m } else { for (File next : file.listFiles()) { recursiveDelete(root, next); } if (!file.equals(root)) { // don't delete root directory file.delete(); } } } public static void delete(final File file) { recursiveDelete(file, file); } }