Here you can find the source of deleteFolder(File folder)
public static void deleteFolder(File folder) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { public static void deleteFolder(File folder) throws IOException { if (!folder.exists()) throw new IOException("" + folder + " doesn't exist."); if (!folder.isDirectory()) throw new IOException("" + folder + " is not a folder."); for (File fileOrFolder : folder.listFiles()) { if (fileOrFolder.isDirectory()) { deleteFolder(fileOrFolder); fileOrFolder.delete();/* w w w . java 2 s.c o m*/ } else fileOrFolder.delete(); } folder.delete(); } }