Here you can find the source of recursiveDelete(File file)
public static int recursiveDelete(File file)
//package com.java2s; /**/* w w w .j a v a2 s. co m*/ * Copyright 2016 Red Hat, Inc. and/or its affiliates. * * Licensed under the Eclipse Public License version 1.0, available at * http://www.eclipse.org/legal/epl-v10.html */ import java.io.File; public class Main { /** * Recursively deletes the given file whether its a file or directory returning the number of files deleted */ public static int recursiveDelete(File file) { int answer = 0; if (file.isDirectory()) { File[] files = file.listFiles(); if (files != null) { for (File child : files) { answer += recursiveDelete(child); } } } if (file.delete()) { answer += 1; } return answer; } }