Here you can find the source of deleteDirectory(final File directory)
public static boolean deleteDirectory(final File directory)
//package com.java2s; //License from project: Open Source License import java.io.File; public class Main { public static boolean deleteDirectory(final File directory) { if (directory == null) { return false; }/* w w w . j av a2s .co m*/ final File[] files = directory.listFiles(); for (int num = files.length, i = 0; i < num; ++i) { if (files[i].isDirectory()) { if (!deleteDirectory(files[i])) { return false; } } else if (!files[i].delete()) { return false; } } return directory.delete(); } }