Here you can find the source of deleteDir(File directory)
private static void deleteDir(File directory)
//package com.java2s; import java.io.File; public class Main { private static void deleteDir(File directory) { if (directory.exists()) { String[] children = directory.list(); if (children != null) { for (int i = 0; i < children.length; i++) { deleteDir(new File(directory, children[i])); }//from ww w. j a v a 2s.c o m } } directory.delete(); } }