Java Delete Tree delTree(File dir, boolean deleteDirItSelf)

Here you can find the source of delTree(File dir, boolean deleteDirItSelf)

Description

File management utilities

License

Open Source License

Declaration


public static void delTree(File dir, boolean deleteDirItSelf) 

Method Source Code

//package com.java2s;

import java.io.File;

public class Main {
    /**/* w w w.j a  v a  2 s.  c  o m*/
     * 
     * File management utilities 
     * 
     */

    public static void delTree(File dir, boolean deleteDirItSelf) {
        if (!dir.exists())
            return;
        for (File subFile : dir.listFiles()) {
            // String name = subFile.getName();
            if (subFile.isDirectory()) {
                delTree(subFile, true);
            }
            subFile.delete();
        }
        if (deleteDirItSelf) {
            dir.delete();
        }
    }
}

Related

  1. deleteTree(File f)
  2. deleteTree(File file, boolean check)
  3. deleteTree(final File file)
  4. delTree(File dir)
  5. delTree(File dir)
  6. deltree(File directory)
  7. delTree(File directory)
  8. delTree(File f)
  9. delTree(File file)