public static List < File > pathsFiles ( final String paths , final Predicate < File > predicate ) { final List < File > files = new ArrayList < File > ( ) ; for ( final String filePathAndName : paths . split ( File . pathSeparator ) ) { final File file = new File ( filePathAndName ) ; if ( file . isDirectory ( ) ) { try ( final Stream < Path > stream = Files . walk ( file . toPath ( ) , Integer . MAX_VALUE ) ) { stream . map ( f -> f . toFile ( ) ) . filter ( predicate ) . forEach ( files :: add ) ; } catch ( final IOException ex ) { throw new RuntimeException ( "Error walking path: " + file , ex ) ; } } else { if ( predicate . test ( file ) ) { files . add ( file ) ; } } } return files ; }
Returns a list of files from all given paths .