Here you can find the source of deleteFile(File file)
public static boolean deleteFile(File file)
//package com.java2s; import java.io.File; public class Main { public static boolean deleteFile(File file) { if (file != null && file.exists()) { if (file.isFile()) { return file.delete(); } else { for (File f : file.listFiles()) { deleteFile(f);/* w w w . j a va 2 s . c o m*/ } return file.delete(); } } return false; } }