Java Delete Tree delTree(File root)

Here you can find the source of delTree(File root)

Description

Delete an entire tree with files, subdirectories, etc.

License

Apache License

Parameter

Parameter Description
root the directory tree to delete

Declaration

public static void delTree(File root) 

Method Source Code

//package com.java2s;
// (as allowed under the Apache License 2.0)

import java.io.File;

public class Main {
    /**//ww w  . j  av a 2s.  c  o  m
     * Delete an entire tree with files, subdirectories, etc.
     *
     * CAREFUL, DANGEROUS!
     *
     * @param root
     *            the directory tree to delete
     */
    public static void delTree(File root) {
        if (!root.isDirectory())
            throw new IllegalArgumentException("Not a directory: " + root);
        for (File f : root.listFiles()) {
            if (f.isDirectory())
                delTree(f);
            else
                f.delete();
        }
        root.delete();
    }
}

Related

  1. delTree(File file)
  2. delTree(File file)
  3. delTree(File file)
  4. delTree(File file)
  5. delTree(File file)
  6. deltree(File root)
  7. deltree(final String directory)
  8. deltree(String dir)
  9. deltree(String dir)