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));
        }
    }
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.

@param file the file to test
@param patterns the array of patterns used to test the file
@return <code>true</code> if one of the regular expressions matches the
file content; otherwise <code>false</code>
@throws java.io.IOException thrown if there is an error reading the file