title: Is there a way to generate and collect objects -on the fly- with a stream of another type?
body: <p>I need to create a new set of <code>objects(synsets)</code> from a stream of Strings, then collect them in a <code>HashSet</code>. I'm trying to do this in a <code>.forEach</code> to avoid collecting the strings and then create the <code>objects(synsets)</code> for each of the strings and then collecting them again in a set.</p>
  
  <pre><code>try (Stream&lt;String&gt; reader = Files.lines(Path)) {
      reader.filter(s -&gt; !s.startsWith(" "))
              .forEach(set.add(new Synset(s)));
  }
  </code></pre>