title: How to shuffle a stream using the Stream API?
body: <p>I decided to take the functional approach in generating a string or random characters, so far I came up with this, it should perform better than boxing and then using a <code>StringJoiner</code> as collector:</p>
  
  <pre><code>Random random = new Random();
  String randomString = IntStream.concat(
          random.ints(8, 'a', 'z'),
          random.ints(8, 'A', 'Z')
  )
          .collect(
                  StringBuilder::new,
                  (sb, i) -&gt; sb.append((char)i),
                  (sb1, sb2) -&gt; sb1.append(sb2)
          ).toString();
  </code></pre>
  
  <p>I want to generate a stream of 16 characters, ranging from a-z or A-Z, the problem I have is that I do not know how to shuffle both streams.</p>
  
  <p>I know that I am using <code>IntStream.concat</code> here,  which will simply concatenate both streams, I'm looking for either of the following:</p>
  
  <ul>
  <li>A static operator like <code>IntStream.concat</code> that does the shuffling when merging the streams.</li>
  <li>A stream operator like <code>sorted()</code>.</li>
  </ul>
  
  <p>Both ways are viable in my opinion, however I am especially intrigued by how to make an operator alike <code>sorted()</code>. The key point here is that it is an operator that is stateful as it needs to see the whole stream before it can operate, is there a way to inject a stateful operator in a stream sequence?</p>
  
  <p>So far the operations, excluding the needed work to shuffle them, seem to not be appropiate for a functional approach in Java 8.</p>