Here you can find the source of recursiveDelete(File file)
Parameter | Description |
---|---|
file | a parameter |
public static boolean recursiveDelete(File file)
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { /**/*from ww w . j av a2 s . c o m*/ * Recursively deletes a file/folder structure. True is returned if ALL * files were deleted. If it returns false, some or none of the files * may have been deleted. * * @param file * @return */ public static boolean recursiveDelete(File file) { //Hopefully this works around JVM bugs. //It seems that on windows machines, until garbage //collection happens, the system will still //have file locks on the file, even if the Streams //were properly closed. System.gc(); if (file.isDirectory()) { boolean ret = true; for (File f : file.listFiles()) { if (!recursiveDelete(f)) { ret = false; } } if (!file.delete()) { ret = false; } return ret; } else { return file.delete(); } } }