title: Reusing Streams in Java 8
body: <p>I need to calculate the ratio of two parts of the big List, wherein the first part contains the second:</p>
  
  <pre><code>Stream&lt;Element&gt; part1 = list.stream().filter(x -&gt; x.getN1() &lt; x.getN2);
  int result = part1.filter(y -&gt; y.isRight()).count() / part1.count();
  </code></pre>
  
  <p>But this code throws the Exception: <strong>java.lang.IllegalStateException: stream has already been operated upon or closed</strong></p>
  
  <p>Can I write a code without creating the same <em>part1</em> stream in <em>result</em>?</p>