question: private FileList filter ( boolean keep , String pattern ) { boolean start = false ; if ( pattern . endsWith ( "*" ) ) { pattern = pattern . substring ( 0 , pattern . length ( ) - 1 ) ; start = true ; } else if ( pattern . startsWith ( "*" ) ) { pattern = pattern . substring ( 1 ) ; } if ( pattern . indexOf ( '*' ) >= 0 ) { throw new RuntimeException ( "Unsupported pattern, may only start or end with *:" + pattern ) ; } pattern = BuildBase . replaceAll ( pattern , "/" , File . separator ) ; FileList list = new FileList ( ) ; for ( File f : this ) { String path = f . getPath ( ) ; boolean match = start ? path . startsWith ( pattern ) : path . endsWith ( pattern ) ; if ( match == keep ) { list . add ( f ) ; } } return list ; }
target:  Filter a list of file names.