Here you can find the source of cleanDirectory(File directory)
public static void cleanDirectory(File directory)
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { public static void cleanDirectory(File directory) { File[] files = directory.listFiles(); if (files != null) { for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) { cleanDirectory(files[i]); }/*from www.ja v a 2 s . co m*/ files[i].delete(); } } } }