Here you can find the source of recursiveRemoveDir(File dir)
public static void recursiveRemoveDir(File dir)
//package com.java2s; import java.io.File; public class Main { public static void recursiveRemoveDir(File dir) { // System.out.println("DEBUG: recursiveRemoveDir: " + dir.getPath()); if (dir == null || !dir.exists()) { return; }/* www . ja va 2s.co m*/ File[] files = dir.listFiles(); for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) { recursiveRemoveDir(files[i]); } else { if (!files[i].delete()) { System.out.println("ERROR: unable to delete file: " + files[i].getPath()); } } } if (!dir.delete()) { System.out.println("ERROR: unable to delete directory: " + dir.getPath()); } } }