public static boolean contains ( File file , String [ ] patterns ) throws IOException { final List < Pattern > regexes = new ArrayList <> ( ) ; for ( String pattern : patterns ) { regexes . add ( Pattern . compile ( pattern ) ) ; } try ( Scanner fileScanner = new Scanner ( file , UTF_8 ) ) { return regexes . stream ( ) . anyMatch ( ( regex ) - > ( fileScanner . findWithinHorizon ( regex , 0 ) != null ) ) ; } }
Determines if the given file contains the given regular expressions .