Java File Path Delete deleteAll(File path)

Here you can find the source of deleteAll(File path)

Description

delete all files and folders under this path

License

Apache License

Parameter

Parameter Description
path a parameter

Declaration

public static final void deleteAll(File path) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.File;

public class Main {
    /**/*  w w  w  .  ja  va2 s .co  m*/
     * delete all files and folders under this path
     * 
     * @param path
     */
    public static final void deleteAll(File path) {
        if (path.isDirectory()) {
            for (File f : path.listFiles()) {
                deleteAll(f);
            }

            if (path.listFiles().length == 0) {
                path.delete();
            }
        } else {
            path.delete();
        }
    }

    public static final void deleteAll(String path) {
        deleteAll(new File(path));
    }
}

Related

  1. delete(String filePath, boolean recursive)
  2. delete(String path)
  3. delete(String path)
  4. delete(String path)
  5. delete(String path)
  6. deleteAll(File path)
  7. deleteAll(File path)
  8. deleteAllFile(final File dir)
  9. deleteAllFile(String directory)