code: public static boolean contains(File file, String pattern) throws IOException {
          try (Scanner fileScanner = new Scanner(file, UTF_8)) {
              final Pattern regex = Pattern.compile(pattern);
              if (fileScanner.findWithinHorizon(regex, 0) != null) {
                  return true;
              }
          }
          return false;
      }
docs: Determines if the given file contains the given regular expression.
  
  @param file the file to test
  @param pattern the pattern used to test the file
  @return <code>true</code> if the regular expression matches the file
  content; otherwise <code>false</code>
  @throws java.io.IOException thrown if there is an error reading the file