Here you can find the source of emptyDirectory(final File directory)
public static void emptyDirectory(final File directory) throws IOException
//package com.java2s; //License from project: BSD License import java.io.File; import java.io.IOException; public class Main { public static void emptyDirectory(final File directory) throws IOException { for (final File file : directory.listFiles()) { if (file.isDirectory()) { emptyDirectory(file);/*from w w w . j av a2 s.c om*/ } if (!file.delete()) { throw new IOException("Can't delete " + file); } } } }