Java File Path Delete delete(File path)

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

Description

delete

License

Open Source License

Declaration

public static boolean delete(File path) 

Method Source Code

//package com.java2s;
import java.io.File;

public class Main {

    public static boolean delete(File path) {

        if (null == path || !path.exists()) {
            return false;
        }//from   w w w .j  ava  2  s.c  o  m

        boolean delete = false;
        if (path.isDirectory()) {
            File[] files = path.listFiles();
            if (null != files && files.length > 0) {
                for (File file : files) {
                    delete(file);
                }
            }
            System.out.println("delete dir: " + path.getAbsolutePath());
            delete = path.delete();
        } else {
            System.out.println("delete file: " + path.getAbsolutePath());
            delete = path.delete();
        }
        return delete;
    }
}

Related

  1. delDirAndFile(String tempath)
  2. deleleFiles(String regex, String path)
  3. delEmptyPath(String path)
  4. delete(File path)
  5. delete(File path)
  6. delete(File path)
  7. delete(File path)
  8. delete(File path, String... exclude)
  9. delete(final File path)