Here you can find the source of deleteFolder(String pathToRootFolder)
public static void deleteFolder(String pathToRootFolder)
//package com.java2s; //License from project: Open Source License import java.io.File; public class Main { public static void deleteFolder(String pathToRootFolder) { File rootFolder = new File(pathToRootFolder); deleteFolder(rootFolder);/*from ww w . j a v a 2 s . c o m*/ } public static void deleteFolder(File rootFolder) { if (!rootFolder.isDirectory()) { rootFolder.delete(); return; } File[] containFiles = rootFolder.listFiles(); for (File currFile : containFiles) { deleteFolder(currFile); } rootFolder.delete(); } }