Here you can find the source of deleteDirectory(File file)
public static void deleteDirectory(File file) throws IOException
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.IOException; public class Main { public static void deleteDirectory(File file) throws IOException { if (file.isDirectory()) { if (file.list().length == 0) { file.delete();//from w w w .j ava2s . co m } else { String files[] = file.list(); for (String temp : files) { File fileDelete = new File(file, temp); deleteDirectory(fileDelete); } if (file.list().length == 0) { file.delete(); } } } else { file.delete(); System.out.println("File is deleted : " + file.getAbsolutePath()); } } }