/**
   * Checks if the logs of the given run match any of the given patterns, line-by-line.
   *
   * @param matrixRun The run to be considered.
   * @param patterns The patterns to match with.
   * @return True if at least one line of the logs match at least one of the given patterns.
   * @throws IOException If there's a problem reading the log file.
   */
  private boolean matchesPattern(MatrixRun matrixRun, List<Pattern> patterns) throws IOException {
    if (patterns == null || patterns.isEmpty()) {
      return true; // No specific patterns specified. Accept everything.
    }

    BufferedReader reader =
        new BufferedReader(
            new InputStreamReader(
                new FileInputStream(matrixRun.getLogFile()), matrixRun.getCharset()));
    try {
      for (String line = reader.readLine(); line != null; line = reader.readLine()) {
        for (Pattern pattern : patterns) {
          Matcher matcher = pattern.matcher(line);
          if (matcher.find()) {
            return true;
          }
        }
      }
    } finally {
      reader.close();
    }
    return false;
  }
  public ArrayList<String> readFile(String filePath)
      throws java.io.FileNotFoundException, java.io.IOException {
    ArrayList<String> aList = new ArrayList<String>();

    try {
      final InputStream is = this.getClass().getResourceAsStream(filePath);
      try {
        final Reader r = new InputStreamReader(is);
        try {
          final BufferedReader br = new BufferedReader(r);
          try {
            String line = null;
            while ((line = br.readLine()) != null) {
              aList.add(line);
            }
            br.close();
            r.close();
            is.close();
          } finally {
            try {
              br.close();
            } catch (IOException e) {
              e.printStackTrace();
            }
          }
        } finally {
          try {
            r.close();
          } catch (IOException e) {
            e.printStackTrace();
          }
        }
      } finally {
        try {
          is.close();
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
    } catch (IOException e) {
      // failure
      e.printStackTrace();
    }

    return aList;
  }