Here you can find the source of delete(final File directory, final FileFilter fileFilter)
public static void delete(final File directory, final FileFilter fileFilter) throws IOException
//package com.java2s; import java.io.File; import java.io.FileFilter; import java.io.FileNotFoundException; import java.io.IOException; import java.nio.file.Files; public class Main { public static void delete(final File directory, final FileFilter fileFilter) throws IOException { if (!directory.exists() || !directory.isDirectory()) throw new FileNotFoundException("No directory found at " + directory); for (File file : directory.listFiles(fileFilter)) Files.delete(file.toPath()); }/*from w w w.java2s . co m*/ }