private static void delete(File directory) { for (File file : directory.listFiles()) { if (file.isDirectory()) { delete(file); } else { assertTrue(file.delete()); } } assertTrue(directory.delete()); }
public static boolean recurseDelete(File f) { if (f.isDirectory()) { for (File sub : f.listFiles()) { if (!recurseDelete(sub)) { System.err.println( "!!!! WARNING: best effort to remove " + sub.getAbsolutePath() + " FAILED !!!!!"); return false; } } } return f.delete(); }