Here you can find the source of deleteDirectory(File f)
Parameter | Description |
---|---|
f | The directory to delete. |
Parameter | Description |
---|---|
IOException | If the file does not exist. |
public static void deleteDirectory(File f) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; public class Main { /**/*from ww w . j a va2s . c o m*/ * Recursive delete method for deleting directories. * * @param f The directory to delete. * @throws IOException If the file does not exist. */ public static void deleteDirectory(File f) throws IOException { // if directory, delete all files in directory if (f.isDirectory()) { // delete files for (File c : f.listFiles()) deleteDirectory(c); } // delete file if (!f.delete()) { throw new FileNotFoundException("Failed to delete file: " + f); } } }