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 (file.isFile()) file.delete();/*from w w w . j av a2s . co m*/ else if (file.isDirectory()) { File[] files = file.listFiles(); if (files != null && files.length > 0) { for (File f : files) { delete(f); } } file.delete(); } } }