title: Java 8 streams on string arrays
body: <p>I have a single String of format:</p>
  
  <pre><code>row1col1 row1col2
  row2col1 row2col2
  row3col1 row3col2
  </code></pre>
  
  <p>and so on...</p>
  
  <p>I want to extract each item and build an array of objects with properties like this:</p>
  
  <pre><code>new MyObject(row1col1, row1col2); 
  </code></pre>
  
  <p>I am new to Java 8 and Streams and I would like to find out how can I achieve this without loops.</p>
  
  <p>Normally I would use a <code>String.split('\n')</code> for accumulating the rows into an array of String</p>
  
  <p>And then a loop where for each line I would split again on the space separator and with the resulting array of the two elements (<code>row1col1 row1col2</code>) build my object, until there are no more rows to process.</p>
  
  <p>Like this:</p>
  
  <pre><code>String sausage = "row1col1 row1col2\nrow2col1 row2col2\nrow3col1 row3col2";
  String[] rows = sausage.split("\n");
  
  for (String row : rows) {
      String[] objectData = u.split("\\s+");
      MyObject myObject = new MyObject(objectData[0], objectData[1]);
      myObjectList.add(myObject);
  }
  </code></pre>
  
  <p>Can anyone explain me how to achieve the same with streams and what is the mechanism behind that allows me to do so?</p>
  
  <p>Is this even a valid way of thinking when increasing the number of elements because from all the examples I've seen the streams focus on filtering, collecting or generally given a set of elements retrieve a minor set applying some criterias.</p>