Java File Path Delete deleteFolderAndContent(String folderPath)

Here you can find the source of deleteFolderAndContent(String folderPath)

Description

Function that deletes a folder and its content.

License

Open Source License

Parameter

Parameter Description
folderPath a parameter

Declaration

public static void deleteFolderAndContent(String folderPath) 

Method Source Code

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

import java.io.File;

public class Main {
    /**/*from  w ww.  j a  v  a 2 s .  c o  m*/
     * Function that deletes a folder and its content.
     * @param folderPath
     */
    public static void deleteFolderAndContent(String folderPath) {
        File index = new File(folderPath);
        String[] entries = index.list();
        for (String s : entries) {
            File currentFile = new File(index.getPath(), s);
            currentFile.delete();
        }
        index.delete();
    }
}

Related

  1. deleteFolder(String path)
  2. deleteFolder(String path)
  3. deleteFolder(String pathToRootFolder)
  4. deleteFolder(String pFolderPath)
  5. deleteFolder(String sPath)
  6. deleteFolderRec(File path, boolean alsoDeleteGivenFolder)
  7. deleteFolderRecursively(File path, boolean includeSelf)
  8. deleteIfExist(String filePath)
  9. deleteInPathTempFiles(String workingFolder)