Java tutorial
//package com.java2s; import java.io.File; public class Main { public static boolean debugRmDir(String dir, boolean deleteDirectory) { File directory = new File(dir); if (directory.isDirectory()) { String[] children = directory.list(); for (String s : children) { if (!debugRmDir(dir + File.separator + s, true)) return false; } } return !deleteDirectory || directory.delete(); } }