title: Printing out each line of a text file in Java that only contains a specific String?
body: <p>I'm a bit of a beginner to OOP and was wondering if I could some help on this issue. </p>
  
  <p>How would I go about writing some code that would read each line of a text file, and then only print out each line of the textfile that contains a certain bit of string.</p>
  
  <p>So, for example, lets imagine I have a example.txt file with the following contents:</p>
  
  <pre><code>OK Print this Line;
  OK Print this Line;
  NO Do not Print this Line;
  OK Print this Line;
  NO Do not Print this Line;
  </code></pre>
  
  <p>Is there anyway to get Java to print out only the lines with the string "OK" in it, and do so in a similar format? (So with newline breaks). So I would want Java to print this out:</p>
  
  <pre><code>OK Print this Line;
  OK Print this Line;
  OK Print this Line;
  </code></pre>
  
  <p>I've been scouring the internet and trying to think of some ways to do this, but I'm really stuck. Is it possible to do this?</p>
  
  <p>Thanks in advance - if you need any more information, please feel free to ask.</p>