title: Java 8 streams conditional processing
body: <p>I'm interested in separating a stream into two or more substreams, and processing the elements in different ways. For example, a (large) text file might contain lines of type A and lines of type B, in which case I'd like to do something like:</p>
  
  <pre><code>File.lines(path)
  .filter(line -&gt; isTypeA(line))
  .forEachTrue(line -&gt; processTypeA(line))
  .forEachFalse(line -&gt; processTypeB(line))
  </code></pre>
  
  <p>The previous is my attempt at abstracting the situation. In reality I have a very large text file where each line is testing against a regex; if the line passes, then it is processed, whereas if it is rejected, then I want to update a counter. This further processing on rejected strings is why I don't simply use <code>filter</code>.</p>
  
  <p>Is there any reasonable way to do this with streams, or will I have to fallback to loops? (I would like this to run in parallel as well, so streams are my first choice).</p>