Here you can find the source of deleteDirectory(String path)
public static void deleteDirectory(String path) throws NoSuchFileException, IOException
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.IOException; import java.nio.file.NoSuchFileException; public class Main { public static void deleteDirectory(String path) throws NoSuchFileException, IOException { File file = new File(path); File[] contents = file.listFiles(); if (contents != null) { for (File f : contents) { f.delete();/*from ww w.j a v a 2 s .c o m*/ } } file.delete(); } }