title: How to partition a list by predicate using java8?
body: <p>I have a list <code>a</code> which i want to split to few small lists.</p>
  
  <p>say all the items that contains with "aaa", all that contains with "bbb" and some more predicates.</p>
  
  <p>How can I do so using java8?</p>
  
  <p>I saw this <a href="http://www.leveluplunch.com/java/examples/partition-list/" rel="noreferrer">post</a> but it only splits to 2 lists.</p>
  
  <pre><code>public void partition_list_java8() {
  
      Predicate&lt;String&gt; startWithS = p -&gt; p.toLowerCase().startsWith("s");
  
      Map&lt;Boolean, List&lt;String&gt;&gt; decisionsByS = playerDecisions.stream()
              .collect(Collectors.partitioningBy(startWithS));
  
      logger.info(decisionsByS);
  
      assertTrue(decisionsByS.get(Boolean.TRUE).size() == 3);
  }
  </code></pre>
  
  <p>I saw this <a href="https://stackoverflow.com/questions/2895342/java-how-can-i-split-an-arraylist-in-multiple-small-arraylists">post</a>, but it was very old, before java 8.</p>