title: How do I get the iterator returned from `Stream#iterator()` to be lazy?
body: <p>Given this code:</p>
  
  <pre><code>@Test
  public void test() throws Exception
  {
      Iterator&lt;Integer&gt; iterator = Stream
          .of(0, 2)
          .flatMap(x -&gt; Stream.of(x, x + 1))
          .map(element -&gt; {
              System.out.println("Stream generating element: " + element);
              return element;
          })
          .iterator();
  
      while (iterator.hasNext())
      {
          Integer value = iterator.next();
          System.out.println("Iterated value: " + value);
      }
  }
  </code></pre>
  
  <p>What I expected to see:</p>
  
  <pre><code>Stream generating element: 0
  Iterated value: 0
  Stream generating element: 1
  Iterated value: 1
  Stream generating element: 2
  Iterated value: 2
  Stream generating element: 3
  Iterated value: 3
  </code></pre>
  
  <p>What I actually see:</p>
  
  <pre><code>Stream generating element: 0
  Stream generating element: 1
  Iterated value: 0
  Iterated value: 1
  Stream generating element: 2
  Stream generating element: 3
  Iterated value: 2
  Iterated value: 3
  </code></pre>
  
  <p>We had been relying on <code>Stream#iterator()</code> returning a lazy iterator, but it seems that in some situations, such as this one, it walks more elements than you have asked for. This is catastrophic if, for example, retrieving the next element requires making a multicast DNS request, which would take 6 seconds to come back.</p>
  
  <p>Is there a way to avoid this and get a truly lazy iterator without implementing my own iterator manually somehow (something which I'm not entirely sure how to even do)?</p>