Here you can find the source of deleteAllFilesInDir(File dir)
public static boolean deleteAllFilesInDir(File dir)
//package com.java2s; //License from project: Open Source License import java.io.File; public class Main { public static boolean deleteAllFilesInDir(File dir) { if (dir.isDirectory()) { boolean result = true; File[] filelist = dir.listFiles(); for (int i = 0; i < filelist.length; i++) { result &= deleteAllFilesInDir(filelist[i]); }/* ww w.j av a 2 s . c o m*/ return result; } else { return dir.delete(); } } }