Here you can find the source of deleteDirRecursive(String path)
public static boolean deleteDirRecursive(String path)
//package com.java2s; //License from project: Apache License import java.io.File; public class Main { public static boolean deleteDirRecursive(String path) { return deleteDirRecursive(new File(path)); }// w ww.j av a2 s .c o m public static boolean deleteDirRecursive(File dir) { if (dir.exists()) { if (!dir.isDirectory()) { throw new IllegalArgumentException("" + dir + " is not directory"); } File[] files = dir.listFiles(); for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) { deleteDirRecursive(files[i]); } else { files[i].delete(); } } } return (dir.delete()); } }