Here you can find the source of delete(File dir)
protected static void delete(File dir)
//package com.java2s; //License from project: Open Source License import java.io.File; public class Main { protected static void delete(File dir) { if (dir.exists() && dir.isDirectory()) { for (File file : dir.listFiles()) { if (file.isDirectory()) { delete(file);/* ww w. ja v a2 s . c om*/ } file.delete(); } } } }