Here you can find the source of delete(File file)
public static void delete(File file)
//package com.java2s; //License from project: Apache License import java.io.File; public class Main { public static void delete(File file) { if (writeable(file)) { if (file.isDirectory()) { for (File f : file.listFiles()) delete(f);// w w w . j a v a2 s .c o m } file.delete(); } } public static boolean writeable(File file) { return (file != null && file.exists() && file.canWrite()); } }