title: Add to a list and using a subset of that list to call a function
body: <p>I have 2 functions. function1 returns 100 (or less) items in one call. function 2 takes a list with size of 150 items as input.
  I have to call funciton1 in a loop and use that input to call function 2. My current logic looks like this:</p>
  <p>'''</p>
  <p>//START</p>
  <pre><code>    int f2FetchSize = 150;
      boolean allDataNotFetched = true;
      List&lt;Item&gt; inputToFunciton2 = new ArrayList&lt;&gt;();
      
      while (allDataNotFetched) {
          List&lt;Item&gt; items = function1();
          if (items.size() == 0) allDataNotFetched = false;
          items.forEach(item -&gt; {
              inputToFunciton2.add(item);
              if (inputToFunciton2.size() == f2FetchSize) {
                  List&lt;Item&gt; temp = new ArrayList&lt;&gt;();
                  temp.addAll(inputToFunciton2);
                  function2(temp);
                  inputToFunciton2.clear();
              }
          });
      }
  </code></pre>
  <p>//END
  '''</p>
  <p>Looking for a better way to write this. Using streams(?) or any other way.
  I have not tried to run this yet as I am still coding the rest of the functionality.</p>
  <p>Thanks in advance.</p>