Here you can find the source of deleteDir(String dirName)
public static void deleteDir(String dirName) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.IOException; import java.nio.file.Files; public class Main { public static void deleteDir(String dirName) throws IOException { deleteDir(new File(dirName)); }// ww w. ja v a 2 s . c o m public static void deleteDir(File dir) throws IOException { if (!dir.exists()) return; if (dir.isDirectory()) { String[] children = dir.list(); for (int i = 0; i < children.length; i++) { deleteDir(new File(dir, children[i])); } } // The directory is now empty so delete it // NB The Files class was introduced in Java 7, this won't compile in earlier Java versions Files.delete(dir.toPath()); } }