Here you can find the source of delete(File file)
public static void delete(File file) throws IOException
//package com.java2s; import java.io.File; import java.io.IOException; public class Main { public static void delete(File file) throws IOException { if (file.isDirectory() && file.list().length > 0) { String files[] = file.list(); for (String tmpFile : files) { File fileToDelete = new File(file, tmpFile); delete(fileToDelete);/*ww w.ja va 2 s .c o m*/ } } file.delete(); } }