Here you can find the source of emptyDir(File directory)
public static void emptyDir(File directory)
//package com.java2s; /*/* w ww .jav a2 s. c o m*/ * Copyright (c) 2013, 2014 Chris Newland. * Licensed under https://github.com/AdoptOpenJDK/jitwatch/blob/master/LICENSE-BSD * Instructions: https://github.com/AdoptOpenJDK/jitwatch/wiki */ import java.io.File; public class Main { public static void emptyDir(File directory) { if (directory.exists() && directory.isDirectory()) { File[] contents = directory.listFiles(); for (File file : contents) { if (file.isDirectory()) { emptyDir(file); file.delete(); } else { file.delete(); } } } } }