Here you can find the source of delete(File f)
public static void delete(File f) throws IOException
//package com.java2s; // Licensed under the Academic Free License version 3.0 import java.io.*; public class Main { public static final File[] none = new File[0]; /**//from w ww.ja va2 s. c om * Recursive delete. Actually throw IOException on error. */ public static void delete(File f) throws IOException { if (!f.exists()) return; if (f.isDirectory()) { File[] kids = list(f); for (int i = 0; kids != null && i < kids.length; ++i) delete(kids[i]); } if (!f.delete()) throw new IOException("Cannot delete: " + f); } /** * Same as File.listFiles() */ public static File[] list(File f) { String[] names = f.list(); if (names == null || names.length == 0) return none; File[] files = new File[names.length]; for (int i = 0; i < names.length; ++i) files[i] = new File(f, names[i]); return files; } }