Here you can find the source of delete(File file)
public static boolean delete(File file)
//package com.java2s; //License from project: Apache License import java.io.File; public class Main { /** Recursively deletes a file or directory and its contents; returns false if * something went wrong in the process (which may leave the job partially complete). */ public static boolean delete(File file) { if (file == null) return true; if (!file.isDirectory()) return file.delete(); File[] flist = file.listFiles(); if (flist != null) { boolean r = true; for (File f : flist) { if (!delete(f)) r = false;//from w ww . j a va 2 s . c o m } if (!r) return r; } return file.delete(); } }