Java File Path Delete deleteDirectory(File path)

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

Description

delete Directory

License

Creative Commons License

Declaration

static public boolean deleteDirectory(File path) 

Method Source Code

//package com.java2s;
//License from project: Creative Commons License 

import java.io.File;

public class Main {
    static public boolean deleteDirectory(File path) {
        if (path.exists()) {
            File[] files = path.listFiles();
            for (int i = 0; i < files.length; i++) {
                if (files[i].isDirectory()) {
                    deleteDirectory(files[i]);
                } else {
                    System.out.println("file deleted: " + files[i].getPath());
                    files[i].delete();// ww w. j  a  va2s. c  om
                }
            }
        }
        return (path.delete());
    }
}

Related

  1. deleteDir(final String path)
  2. deleteDir(String path)
  3. deleteDir(String path)
  4. deleteDirByDoc(String path)
  5. deleteDirectory(File directoryPath)
  6. deleteDirectory(File path)
  7. deleteDirectory(File path)
  8. deleteDirectory(File path)
  9. deleteDirectory(File path)