Here you can find the source of recursiveDelete(File file, boolean deleteParentFile)
Parameter | Description |
---|---|
file | a parameter |
deleteParentFile | Whether or not to delete the top level |
public static void recursiveDelete(File file, boolean deleteParentFile)
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { /**/*w w w. j a va2s .c o m*/ * Recursively deletes a file (folder) and all children * * @param file * @see #recursiveDelete(java.io.File,boolean) */ public static void recursiveDelete(File file) { recursiveDelete(file, true); } /** * Recursively deletes a file (folder) and all children * * @param file * @param deleteParentFile Whether or not to delete the top level */ public static void recursiveDelete(File file, boolean deleteParentFile) { File[] files = file.listFiles(); for (int i = 0; i < files.length; i++) { File file1 = files[i]; if (file1.isDirectory()) { recursiveDelete(file1); } else { file1.delete(); } } if (deleteParentFile) { file.delete(); } } }