Java Delete Folder deleteFolder(File file, boolean deleteParent)

Here you can find the source of deleteFolder(File file, boolean deleteParent)

Description

delete Folder

License

Open Source License

Declaration

synchronized public static void deleteFolder(File file, boolean deleteParent) 

Method Source Code


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

public class Main {
    synchronized public static void deleteFolder(File file, boolean deleteParent) {
        File[] list = file.listFiles();
        if (list == null || list.length < 1) {
            if (deleteParent)
                file.delete();//from  w ww  . jav  a 2  s. com
            return;
        }
        for (File ele : list) {
            if (ele.isDirectory())
                deleteFolder(ele, true);
            else
                ele.delete();
        }
        if (deleteParent)
            file.delete();
    }
}

Related

  1. deleteFolder(@Nonnull File file)
  2. deleteFolder(File dir, boolean deleteFolderItself)
  3. deleteFolder(File file)
  4. deleteFolder(File file)
  5. deleteFolder(File file)
  6. deleteFolder(File file, boolean withCurrentFolder)
  7. deleteFolder(File folder)
  8. deleteFolder(File folder)
  9. deleteFolder(File folder)