Here you can find the source of deleteDirectory(String path)
public static void deleteDirectory(String path)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.util.ArrayList; import java.util.List; public class Main { public static void deleteDirectory(String path) { File dirToDel = new File(path); if (dirToDel.exists()) { List<File> files = getFilesInDir(dirToDel); for (File f : files) { f.delete();//from w w w .j a v a2s .c o m } dirToDel.delete(); } } public static List<File> getFilesInDir(File dir) { List<File> output = new ArrayList<>(); for (File file : dir.listFiles()) { if (file.isDirectory()) output.addAll(getFilesInDir(file)); else output.add(file); } return output; } }