Java tutorial
//package com.java2s; import java.io.File; public class Main { public static boolean deleteDir(File dir) { if (dir != null && dir.isDirectory()) { String[] children = dir.list(); for (String aChildren : children) { boolean success = deleteDir(new File(dir, aChildren)); if (!success) { return false; } } } // The directory is now empty so delete it return dir != null && dir.delete(); } }