In this recipe, you will learn how to create streams from different sources. You have different options, as the following:
- The parallelStream() method of the Collection interface
- The Supplier interface
- A predefined set of elements
- File and a directory
- An array
- A random number generator
- The concatenation of two different streams
You can create a Stream object from other sources (that will be described in the There's more section), but we think that these are the more useful.