Here you can find the source of recursiveDelete(File pathToFolderOrFile)
Parameter | Description |
---|---|
pathToFolderOrFile | a parameter |
public static boolean recursiveDelete(File pathToFolderOrFile)
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { /**// ww w .j a v a2 s . co m * Deletes file or folder. Folder could contain files or even other folders * * @param pathToFolderOrFile * @return */ public static boolean recursiveDelete(File pathToFolderOrFile) { if (pathToFolderOrFile.isFile() && pathToFolderOrFile.exists()) { pathToFolderOrFile.delete(); } else if (pathToFolderOrFile.exists()) { File[] files = pathToFolderOrFile.listFiles(); for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) { recursiveDelete(files[i]); } else { files[i].delete(); } } } return (pathToFolderOrFile.delete()); } }