Here you can find the source of cleanDir(String path)
public static void cleanDir(String path) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.IOException; public class Main { public static void cleanDir(String path) throws IOException { File dir = new File(path); if (dir.exists()) { if (!dir.isDirectory()) { throw new IOException("Path is not a directory: " + path); }/*ww w . j ava 2 s. c o m*/ for (File file : dir.listFiles()) { file.delete(); } } } }