Here you can find the source of delete(File f)
public static final void delete(File f) throws IOException
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; public class Main { public static final void delete(File f) throws IOException { if (f.isDirectory()) { for (File c : f.listFiles()) { delete(c);/* w w w . j a v a 2 s. co m*/ } } if (!f.delete()) { throw new FileNotFoundException("Failed to delete file: " + f.getAbsolutePath()); } } }