Here you can find the source of deleteRecursively(File file)
public static boolean deleteRecursively(File file)
//package com.java2s; //License from project: LGPL import java.io.File; public class Main { public static boolean deleteRecursively(File file) { if (file.isDirectory()) { boolean success = true; for (File child : file.listFiles()) { if (!deleteRecursively(child)) { success = false;//from ww w. j ava2 s. c om } } if (success) { return file.delete(); } else { return success; } } else if (file.isFile()) { return file.delete(); } else { // Does not exist return false; } } }