Here you can find the source of emptyFolder(File folder)
public static void emptyFolder(File folder)
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { public static void emptyFolder(File folder) { if (folder.isDirectory()) { File[] files = folder.listFiles(); for (File file : files) { if (file.isDirectory()) { emptyFolder(file);//from w ww . j av a 2s . c om } else { file.delete(); } } } } }