Here you can find the source of deleteDirectory(File dir)
Parameter | Description |
---|---|
dir | a parameter |
public static boolean deleteDirectory(File dir)
//package com.java2s; import java.io.File; public class Main { /**/*w w w . j ava 2 s.c o m*/ * Deletes the directory and all of its subdirectories and files. * @param dir * @return True if directory is successfully deleted. */ public static boolean deleteDirectory(File dir) { if (dir.isDirectory()) { String[] children = dir.list(); for (int i = 0; i < children.length; i++) { boolean success = deleteDirectory(new File(dir, children[i])); if (!success) { return false; } } } // The directory is now empty so delete it return dir.delete(); } }