private void deleteFiles ( Predicate < File > predicate ) { directory . mkdirs ( ) ; // Iterate through all files in the storage directory. for ( File file : directory . listFiles ( f -> f . isFile ( ) && predicate . test ( f ) ) ) { try { Files . delete ( file . toPath ( ) ) ; } catch ( IOException e ) { // Ignore the exception. } } }
Deletes file in the storage directory that match the given predicate .