Here you can find the source of delete(File f)
public static void delete(File f) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.IOException; public class Main { public static void delete(File f) throws IOException { if (f.isDirectory() && f.listFiles() != null) { final File[] files = f.exists() && f.listFiles() == null ? new File[0] : f.listFiles(); assert files != null; for (File c : files) delete(c);/*w ww . j a v a 2 s . c o m*/ } if (!f.delete()) { throw new IOException("Failed to delete file: " + f); } } }