Here you can find the source of deleteDir(File file)
public static void deleteDir(File file)
//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(File file) { File[] files = file.listFiles(); if (files != null) { for (File temp : files) { deleteDir(temp);//from w w w .j a va 2 s . c o m } } try { Files.deleteIfExists(file.toPath()); } catch (IOException e) { e.printStackTrace(); } } }