The opposite of converting a string to a stream, this example will demonstrate converting a java 8 stream into a string. A Collector is a reduction operation which will gather together elements from a stream into a cumulative result of a String. Collectors.joining() will return a Collector that will concatenates the input elements into a String which has similar behavior to joining strings. If you want to join the string by a delimiter just pass in a CharSequence into the joining method. For instance, if you want to join string by a comma it would look like Collectors.joining(",")
.
Java 8
If you prefer, you could use a static import.