Here you can find the source of deleteFolder(String filePath)
public static void deleteFolder(String filePath)
//package com.java2s; //License from project: Open Source License import java.io.File; public class Main { public static void deleteFolder(String filePath) { File file = new File(filePath); if (file.exists()) { if (file.isFile()) { file.delete();/* w w w .jav a 2 s . co m*/ } else if (file.isDirectory()) { File[] files = file.listFiles(); for (int i = 0; i < files.length; ++i) { deleteFolder(files[i]); } } file.delete(); } } public static void deleteFolder(File file) { if (file.exists()) { if (file.isFile()) { file.delete(); } else if (file.isDirectory()) { File[] files = file.listFiles(); for (int i = 0; i < files.length; ++i) { deleteFolder(files[i]); } } file.delete(); } } }