Here you can find the source of deleteDirContent(File d)
public static void deleteDirContent(File d)
//package com.java2s; import java.io.File; public class Main { public static void deleteDirContent(File d) { if (!d.exists()) return; if (!d.isDirectory()) return; File[] children = d.listFiles(); for (File c : children) { if (c.isDirectory()) deleteDirContent(c);/*w ww .j a v a 2 s . com*/ else deleteFile(c); } } public static void deleteFile(File f) { if (!f.exists()) return; boolean deleted = f.delete(); if (!deleted) throw new IllegalStateException("Could not delete file " + f); } }