Here you can find the source of recursiveDelete(File file)
public static void recursiveDelete(File file) throws IOException
//package com.java2s; /*//from w ww . j a v a 2 s .c o m * Wegas * http://wegas.albasim.ch * * Copyright (c) 2013 School of Business and Engineering Vaud, Comem * Licensed under the MIT License */ import java.io.File; import java.io.IOException; public class Main { public static void recursiveDelete(File file) throws IOException { if (file.isDirectory()) { if (file.list().length == 0) { file.delete(); } else { String files[] = file.list(); for (String f : files) { File fileToDel = new File(file, f); recursiveDelete(fileToDel); } if (file.list().length == 0) { file.delete(); } else { throw new IOException("Could not empty " + file.getName()); } } } else { file.delete(); } } }