Here you can find the source of deleteFolder(String folderPath)
private static void deleteFolder(String folderPath)
//package com.java2s; import java.io.File; public class Main { private static void deleteFolder(String folderPath) { File file = new File(folderPath); if (!file.exists()) { return; }/*from w w w . j ava2s . com*/ if (!recursiveDeleteDirContenteleteDir(file)) { System.err.println("Failed to clean up old resources in " + folderPath + " while setting up additional test resources."); } } public static boolean recursiveDeleteDirContenteleteDir(File dir) { if (dir.isDirectory()) { String[] children = dir.list(); for (int i = 0; i < children.length; i++) { boolean success = recursiveDeleteDirContenteleteDir(new File(dir, children[i])); if (!success) { return false; } } } return dir.delete(); } }