Java Recursive Delete recursiveDelete(File fileOrDir)

Here you can find the source of recursiveDelete(File fileOrDir)

Description

recursive Delete

License

Open Source License

Declaration

public static boolean recursiveDelete(File fileOrDir) 

Method Source Code

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

public class Main {
    public static boolean recursiveDelete(File fileOrDir) {
        if (!fileOrDir.exists()) {
            System.err.println("delete: no such file or directory: "
                    + fileOrDir.getPath());
            return false;
        }/*from  w  w w.ja v a  2  s. c  o m*/

        if (fileOrDir.isDirectory()) {
            // recursively delete contents
            for (File innerFile : fileOrDir.listFiles()) {
                if (!recursiveDelete(innerFile)) {
                    return false;
                }
            }
        }
        //System.err.println("recursive delete = " + fileOrDir.getPath());
        return fileOrDir.delete();
    }
}

Related

  1. recursiveDelete(File file)
  2. recursiveDelete(File file)
  3. recursiveDelete(File file)
  4. recursiveDelete(File file)
  5. recursiveDelete(File file, boolean deleteParentFile)
  6. recursiveDelete(File fileOrDir)
  7. recursiveDelete(File folder)
  8. recursiveDelete(File parent)
  9. recursiveDelete(File pathToFolderOrFile)