title: Best way to check a char sequence on a line
body: <p>I have an input stream which I want to use to read specific messages whether it is contained in the map, e.g.: <code>you must consider : Invalid card number.</code> // this is the line.</p>
  
  <p>I want to check whether this line contains the 'Invalid card number' key of the map.</p>
  
  <p>We have to iterate through the map and checks whether the line contains the message.</p>
  
  <pre><code>String line = "you must consider : Invalid card number.";
  for (String key : map) {
      if(line.contains(key)) {
          throw new Exception(key.value());
      }
  }
  </code></pre>
  
  <p>But then we have to iterate through this map for every line of the stream.</p>
  
  <p>Is this a good practice?</p>