Here you can find the source of deleteDir(File dir)
public static void deleteDir(File dir) throws IOException
//package com.java2s; import java.io.File; import java.io.IOException; public class Main { public static void deleteDir(File dir) throws IOException { if (dir.isFile()) throw new IOException( "IOException -> BadInputException: not a directory."); File[] files = dir.listFiles(); if (files != null) { for (int i = 0; i < files.length; i++) { File file = files[i]; if (file.isFile()) { file.delete();//www. j a v a 2s. co m } else { deleteDir(file); } } }// if dir.delete(); } }