public static List < File > findFilesRecursive ( final File dir , final String extension ) { final String dotExtension = "." + extension ; final List < File > files = new ArrayList <> ( ) ; final FileProcessor fileProcessor = new FileProcessor ( new FileHandler ( ) { @ Override public final FileHandlerResult handleFile ( final File file ) { // Directory if ( file . isDirectory ( ) ) { return FileHandlerResult . CONTINUE ; } // File final String name = file . getName ( ) ; if ( name . endsWith ( dotExtension ) ) { files . add ( file ) ; } return FileHandlerResult . CONTINUE ; } } ) ; fileProcessor . process ( dir ) ; return files ; }
Returns a list of files with a given extension .