Java Delete Folder deleteFolder(File folder)

Here you can find the source of deleteFolder(File folder)

Description

delete Folder

License

Apache License

Declaration

public static boolean deleteFolder(File folder) 

Method Source Code

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

import java.io.File;

public class Main {

    public static boolean deleteFolder(File folder) {
        return deleteFolderContents(folder) && folder.delete();
    }//from   www.j a  v  a 2 s. c  o m

    public static boolean deleteFolderContents(File folder) {
        File[] files = folder.listFiles();
        if (files != null) {
            for (File file : files) {
                if (file.isFile()) {
                    if (!file.delete()) {
                        return false;
                    }
                } else {
                    if (!deleteFolder(file)) {
                        return false;
                    }
                }
            }
        }
        return true;
    }
}

Related

  1. deleteFolder(File file)
  2. deleteFolder(File file, boolean deleteParent)
  3. deleteFolder(File file, boolean withCurrentFolder)
  4. deleteFolder(File folder)
  5. deleteFolder(File folder)
  6. deleteFolder(File folder)
  7. deleteFolder(File folder)
  8. deleteFolder(File folder)
  9. deleteFolder(File folder)