Here you can find the source of deleteFile(File f)
public static boolean deleteFile(File f)
//package com.java2s; import java.io.File; public class Main { public static boolean deleteFile(File f) { if (f.exists()) { if (f.isFile()) return f.delete(); else if (f.isDirectory()) { File[] files = f.listFiles(); for (int i = 0; i < files.length; i++) { if (!deleteFile(files[i])) return false; }// w ww.j a v a 2 s . c om return f.delete(); } else return false; } else return false; } }