Here you can find the source of deleteRecursive(File file)
static void deleteRecursive(File file)
//package com.java2s; //License from project: Apache License import java.io.File; public class Main { static void deleteRecursive(File file) { if (file.isDirectory()) { File[] files = file.listFiles(); if (files != null) { for (File f : files) { deleteRecursive(f);//from www . j av a2 s.c om } if (!file.delete()) { System.out.println("Could not delete folder " + file); } } } else { if (!file.delete()) { System.out.println("Could not delete file " + file); } } } }