Here you can find the source of deleteFile(File path)
public static boolean deleteFile(File path) throws FileNotFoundException
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.FileNotFoundException; public class Main { public static boolean deleteFile(File path) throws FileNotFoundException { if (!path.exists()) { throw new FileNotFoundException(path.getAbsolutePath()); }/*from ww w. j a v a 2 s . c om*/ boolean ret = true; if (path.isDirectory()) { for (File f : path.listFiles()) { ret = ret && deleteFile(f); } } return ret && path.delete(); } }