Here you can find the source of recursiveDelete(File fileOrDir)
public static boolean recursiveDelete(File fileOrDir)
//package com.java2s; import java.io.File; public class Main { public static boolean recursiveDelete(File fileOrDir) { if (!fileOrDir.exists()) { System.err.println("delete: no such file or directory: " + fileOrDir.getPath()); return false; }/*from w w w.ja v a 2 s. c o m*/ if (fileOrDir.isDirectory()) { // recursively delete contents for (File innerFile : fileOrDir.listFiles()) { if (!recursiveDelete(innerFile)) { return false; } } } //System.err.println("recursive delete = " + fileOrDir.getPath()); return fileOrDir.delete(); } }