Here you can find the source of recursiveDelete(File file)
Parameter | Description |
---|---|
file | a parameter |
Parameter | Description |
---|---|
IOException | an exception |
public static boolean recursiveDelete(File file) throws IOException
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.IOException; public class Main { /**//from w w w .j a v a 2 s . co m * Delete a file and all its descendants, indicating success or * failure. * @param file * @throws IOException * @return true if this succeeds, or false if one or more files * or directories can't be deleted. */ public static boolean recursiveDelete(File file) throws IOException { boolean success = true; if (file.isDirectory()) { for (File child : file.listFiles()) { if (!recursiveDelete(child)) { success = false; } } } if (!file.delete()) { success = false; } return success; } }