Here you can find the source of deleteFolder(File folder)
public static boolean deleteFolder(File folder) throws Exception
//package com.java2s; import java.io.File; public class Main { public static boolean deleteFolder(File folder) throws Exception { if (folder.exists()) { if (folder.isDirectory()) { File[] subFiles = folder.listFiles(); for (File subFile : subFiles) { if (subFile.isFile()) { deleteFile(subFile); } else { deleteFolder(subFile); }//w w w . j a v a 2s . c om } } return deleteFile(folder); } else { return false; } } public static boolean deleteFile(File file) throws Exception { if (file.exists()) { return file.delete(); } else { return false; } } }