title: Best way to read lines from file Java 8 and break in between
body: <p>The <code>Files.lines().forEach()</code> method doesn't allow the <code>break</code>. What's the optimal way to read lines in Java 8 in chunks and break when needed?</p>
  
  <p>Update 1:  Example for exception. </p>
  
  <pre><code>public class Main {
  public static void main(String[] args) {
  
      try(IntStream s = IntStream.range(0, 5);){
      s.forEach(i -&gt; validate(i));
  
      }catch(Exception ex){
      System.out.println("Hello World!");    
      }
  }
  static void validate(int s){
  
      if(s &gt; 1){            
          //throw new Exception(); ?
      }
      System.out.println(s);
  } }
  </code></pre>