Here you can find the source of deleteDirectory(File root)
public static void deleteDirectory(File root)
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { public static void deleteDirectory(File root) { if (root == null || !root.exists()) { return; }//from w ww . jav a 2 s. c om if (root.isFile()) { root.delete(); } else if (root.isDirectory()) { File[] children = root.listFiles(); if (children != null) { for (File child : children) { if (child.isFile()) { child.delete(); } else if (child.isDirectory()) { deleteDirectory(child); } } } root.delete(); } } }