Here you can find the source of deleteAllFile(final File dir)
private static boolean deleteAllFile(final File dir)
//package com.java2s; //License from project: Open Source License import java.io.File; public class Main { private static boolean deleteAllFile(final File dir) { boolean deleted = false; if (dir.exists()) { File[] files = dir.listFiles(); for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) { deleteAllFile(files[i]); } else { deleted = files[i].delete(); }//from ww w. ja va2 s . c om } } return deleted; } }