--- old/src/share/classes/java/util/stream/Stream.java 2013-07-04 00:24:31.166329409 -0700 +++ new/src/share/classes/java/util/stream/Stream.java 2013-07-04 00:24:30.986329412 -0700 @@ -883,4 +883,29 @@ return StreamSupport.stream( new StreamSpliterators.InfiniteSupplyingSpliterator.OfRef<>(Long.MAX_VALUE, s)); } + + /** + * Creates a lazy concatenated {@code Stream} whose elements are all the + * elements of a first {@code Stream} succeeded by all the elements of the + * second {@code Stream}. The resulting stream is ordered if both + * of the input streams are ordered, and parallel if either of the input + * streams is parallel. + * + * @param The type of stream elements + * @param a the first stream + * @param b the second stream to concatenate on to end of the first + * stream + * @return the concatenation of the two input streams + */ + public static Stream concat(Stream a, Stream b) { + Objects.requireNonNull(a); + Objects.requireNonNull(b); + + @SuppressWarnings("unchecked") + Spliterator split = new Streams.ConcatSpliterator.OfRef<>( + (Spliterator) a.spliterator(), (Spliterator) b.spliterator()); + return (a.isParallel() || b.isParallel()) + ? StreamSupport.parallelStream(split) + : StreamSupport.stream(split); + } }