Here you can find the source of deleteDir(File dirPath)
public static boolean deleteDir(File dirPath)
//package com.java2s; import java.io.File; public class Main { public static boolean deleteDir(File dirPath) { boolean isOk = true; if (dirPath.isDirectory()) { try { deleteDirs(dirPath);//from ww w .j a v a2 s . c o m } catch (Exception e) { isOk = false; } } return isOk; } public static boolean deleteDir(String path) { return deleteDir(new File(path)); } private static void deleteDirs(File path) { File[] files = null; if (path.isDirectory()) { path.delete(); files = path.listFiles(); if (files != null) { for (int i = 0; i < files.length; i++) { deleteDirs(files[i]); } } } path.delete(); } }