title: Filter stream until Predicate
body: <p>I have a Java 8 stream of objects and I would like to ignore the objects after a given predicate is matched.</p>
  
  <p>Example : I would like to keep all the strings up-to the "BREAK" one (and including it).</p>
  
  <pre><code>public List&lt;String&gt; values = Arrays.asList("some", "words", "before", "BREAK", "AFTER");
  
  @Test
  public void testStopAfter() {
      Stream&lt;String&gt; stream = values.stream();
      //how to filter stream to stop at the first BREAK
      //stream = stream.filter(s -&gt; "BREAK".equals(s));
      final List&lt;String&gt; actual = stream.collect(Collectors.toList());
  
      final List&lt;String&gt; expected = Arrays.asList("some", "words", "before", "BREAK");
      assertEquals(expected, actual);
  }
  </code></pre>
  
  <p>As it is it fails <em>(expected:&lt;[some, words, before, BREAK]> but was:&lt;[some, words, before, BREAK, AFTER]>)</em>, and if I uncomment the filter, I only get the "BREAK"</p>
  
  <p>I am thinking of a statefull Predicate (see my answer below) but I was wandering if there was a nicer solution ?</p>