title: Combine stream of Collections into one Collection - Java 8
body: <p>So I have a <code>Stream&lt;Collection&lt;Long&gt;&gt;</code> that I obtain by doing a series of transformations on another stream.</p>
  
  <p>What I need to do is collect the <code>Stream&lt;Collection&lt;Long&gt;&gt;</code> into one <code>Collection&lt;Long&gt;</code>.</p>
  
  <p>I could collect them all into a list like this:</p>
  
  <pre><code>&lt;Stream&lt;Collection&lt;Long&gt;&gt; streamOfCollections = /* get the stream */;
  
  List&lt;Collection&lt;Long&gt;&gt; listOfCollections = streamOfCollections.collect(Collectors.toList());
  </code></pre>
  
  <p>And then I could iterate through that list of collections to combine them into one.</p>
  
  <p>However, I imagine there must be a simple way to combine the stream of collections into one <code>Collection&lt;Long&gt;</code> using a <code>.map()</code> or <code>.collect()</code>. I just can't think of how to do it. Any ideas?</p>