Here you can find the source of deleteFolder(File file, boolean deleteParent)
synchronized public static void deleteFolder(File file, boolean deleteParent)
//package com.java2s; import java.io.File; public class Main { synchronized public static void deleteFolder(File file, boolean deleteParent) { File[] list = file.listFiles(); if (list == null || list.length < 1) { if (deleteParent) file.delete();//from w ww . jav a 2 s. com return; } for (File ele : list) { if (ele.isDirectory()) deleteFolder(ele, true); else ele.delete(); } if (deleteParent) file.delete(); } }