Here you can find the source of deleteRecursive(final File file)
public static boolean deleteRecursive(final File file)
//package com.java2s; /*####################################################### * * Maintained by Gregor Santner, 2017- * https://gsantner.net///from w w w.j a v a 2 s . c o m * * License: Apache 2.0 * https://github.com/gsantner/opoc/#licensing * https://www.apache.org/licenses/LICENSE-2.0 * #########################################################*/ import java.io.File; public class Main { public static boolean deleteRecursive(final File file) { boolean ok = true; if (file.exists()) { if (file.isDirectory()) { for (File child : file.listFiles()) ok &= deleteRecursive(child); } ok &= file.delete(); } return ok; } }