Java File Path Delete deleteFolder(String pathToRootFolder)

Here you can find the source of deleteFolder(String pathToRootFolder)

Description

delete Folder

License

Open Source License

Declaration

public static void deleteFolder(String pathToRootFolder) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.File;

public class Main {
    public static void deleteFolder(String pathToRootFolder) {
        File rootFolder = new File(pathToRootFolder);

        deleteFolder(rootFolder);/*from ww  w  .  j a  v a 2 s .  c  o  m*/
    }

    public static void deleteFolder(File rootFolder) {
        if (!rootFolder.isDirectory()) {
            rootFolder.delete();
            return;
        }

        File[] containFiles = rootFolder.listFiles();

        for (File currFile : containFiles) {
            deleteFolder(currFile);
        }

        rootFolder.delete();
    }
}

Related

  1. deleteFolder(String path)
  2. deleteFolder(String path)
  3. deleteFolder(String path)
  4. deleteFolder(String path)
  5. deleteFolder(String path)
  6. deleteFolder(String pFolderPath)
  7. deleteFolder(String sPath)
  8. deleteFolderAndContent(String folderPath)
  9. deleteFolderRec(File path, boolean alsoDeleteGivenFolder)