code: protected List<String> findStringsInFileCommon(String regexp,
                                                     boolean stopOnFirst, int searchLimit, File fileToSearch)
                      throws Exception {
          if (fileToSearch == null) {
              log(messages.getString("info.file.validated"));
              return null;
          }
  
          if (!fileToSearch.exists()) {
              log(MessageFormat.format(messages.getString("info.file.validate.noexist"), fileToSearch.getCanonicalPath()));
              return null;
          }
  
          InputStream serverOutput = null;
          InputStreamReader in = null;
          Scanner s = null;
          List<String> matches = null;
          try {
              // Read file and search
              serverOutput = new FileInputStream(fileToSearch);
              in = new InputStreamReader(serverOutput);
              s = new Scanner(in);
  
              log(MessageFormat.format(messages.getString("info.look.string.infile"), regexp, fileToSearch.getName()), Project.MSG_VERBOSE);
  
              String foundString = null;
              Pattern pattern = Pattern.compile(regexp);
  
              matches = new ArrayList<String>();
              while (s.hasNextLine()) {
                  if (foundString != null && stopOnFirst) {
                      break;
                  }
  
                  if (searchLimit <= 0 && searchLimit >= matches.size()) {
                      break;
                  }
  
                  String line = s.nextLine();
                  if (pattern.matcher(line).find()) {
                      foundString = line;
                      matches.add(line);
                      log(MessageFormat.format(messages.getString("info.match.string"), matches.size(), line));
                  }
              }
          } catch (Exception e) {
              log(e.toString());
          } finally {
              try {
                  s.close();
              } catch (Exception e) {
                  // Ignore
              }
  
              try {
                  serverOutput.close();
              } catch (Exception e) {
                  // Ignore
              }
  
              try {
                  in.close();
              } catch (Exception e) {
                  //Ignore
              }
  
          }
  
          return matches;
      }
docs: Searches the given file for the given regular expression.
  
  @param regexp
  a regular expression (or just a text snippet) to search for
  @param fileToSearch
  the file to search
  @return List of Strings which match the pattern. No match results in an
  empty list.
  @throws Exception