Here you can find the source of forceDelete(File file)
private static void forceDelete(File file) throws IOException
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { private static void forceDelete(File file) throws IOException { if (file.isDirectory()) { File[] files = file.listFiles(); for (File child : files) { forceDelete(child);/*w w w.j a v a 2 s . com*/ } deleteFile(file); } else { deleteFile(file); } } public static void deleteFile(File file) throws IOException { if (file == null) { return; } if (!file.delete()) { throw new IOException("Unable to delete file: " + file); } } }