Return to Snippet

Revision: 34931
at October 30, 2010 10:16 by studioevoque


Initial Code
public static boolean deleteDir(File dir) {
     if (dir.isDirectory()) {
         String[] children = dir.list();
         for (int i=0; i<children.length; i++) {
             boolean success = deleteDir(new File(dir, children[i]));
             if (!success) {
                return false;
             }
         }
     }

     // The directory is now empty so delete it
     return dir.delete();
}

Initial URL

                                

Initial Description
A "quick and dirty" way to delete a directory. For more cleaner implementation, see http://www.google.com/codesearch/p?hl=en#SS2by_AKaLs/src/org/apache/commons/io/FileUtils.java&q=cleanDirectory&l=972

Initial Title
Delete a directory

Initial Tags
java, directory

Initial Language
Java