Here you can find the source of deleteDirectory(File f)
public static boolean deleteDirectory(File f) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.IOException; public class Main { public static boolean deleteDirectory(File f) throws IOException { if (f.exists() && f.isDirectory()) { File[] files = f.listFiles(); if (null != files) { for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) { deleteDirectory(files[i]); } else { files[i].delete(); }/*from ww w . j a v a 2 s .c o m*/ } } } else if (f.exists() && f.isFile()) { return f.delete(); } return (f.delete()); } }