Here you can find the source of deleteFolder(File file, boolean withCurrentFolder)
public static void deleteFolder(File file, boolean withCurrentFolder)
//package com.java2s; // %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt import java.io.File; public class Main { /**/* w w w . j a v a2s. c o m*/ * * Delete the sub folders, if true, will delete current folder also. */ public static void deleteFolder(File file, boolean withCurrentFolder) { if (file.exists() && file.isDirectory()) { File files[] = file.listFiles(); for (File file2 : files) { deleteFile(file2, true); } if (withCurrentFolder) { file.delete(); } } } public static void deleteFile(File file, boolean delete) { if (file.exists()) { if (file.isFile() && delete) { file.delete(); } else if (file.isDirectory()) { File files[] = file.listFiles(); for (File file2 : files) { deleteFile(file2, true); } } if (delete) { file.delete(); } } } }