Here you can find the source of deleteDirectoryRecursivelyE(File dir)
public static void deleteDirectoryRecursivelyE(File dir)
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { public static void deleteDirectoryRecursivelyE(File dir) { if (!dir.isDirectory()) throw new RuntimeException("Not a directory: " + dir.getAbsolutePath()); for (File f : dir.listFiles()) { if (f.isDirectory()) { deleteDirectoryRecursivelyE(f); } else { if (!f.delete()) throw new RuntimeException("Failed to delete file: " + f.getAbsolutePath()); }//from w w w . j av a2s. co m } if (!dir.delete()) throw new RuntimeException("Failed to delete directory: " + dir.getAbsolutePath()); } }