public static File [ ] listFiles ( final File target , final List < Pattern > patterns , final boolean include ) { if ( patterns == null || patterns . isEmpty ( ) ) return target . listFiles ( ) ; return target . listFiles ( new FilenameFilter ( ) { @ Override public boolean accept ( File dir , String name ) { for ( Pattern pattern : patterns ) { Matcher matcher = pattern . matcher ( name ) ; if ( matcher . matches ( ) ) return include ; } return ! include ; } } ) ; }
List files according to the patterns and the pattern type