public static void delete(File file) throws IOException {
        if (file.isDirectory()) {
            for (File f : file.listFiles()) {
                delete(f);
            }
        }
        if (file.isDirectory() || file.isFile()) {
            if (!file.delete()) {
                throw new IllegalStateException("Deletion of " + file.getPath() + " failed");
            }
        }
    }
FileUtils provides File handling functionality

@author tiwe
querydsl-core/src/main/java/com/querydsl/core/util/FileUtils.java