Here you can find the source of deleteDir(File directory)
Parameter | Description |
---|---|
directory | The directory to be deleted. |
Parameter | Description |
---|---|
IOException | an exception |
public static boolean deleteDir(File directory) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.IOException; public class Main { /**/* www .j a va 2s .c om*/ * Deletes the given directory. * @param directory The directory to be deleted. * @return true if the directory was deleted; false otherwise. * @throws IOException */ public static boolean deleteDir(File directory) throws IOException { if (directory.isDirectory()) { File[] children = directory.listFiles(); for (File file : children) { boolean success = deleteDir(file); if (!success) { return false; } } } return directory.delete(); } }