public final class StreamSupport extends Object
This class is mostly for library writers presenting stream views
 of data structures; most static stream methods intended for end users are in
 the various Stream classes.
- Since:
- 1.8
- 
Method SummaryModifier and Type Method Description static DoubleStreamdoubleStream(Supplier<? extends Spliterator.OfDouble> supplier, int characteristics, boolean parallel)Creates a new sequential or parallelDoubleStreamfrom aSupplierofSpliterator.OfDouble.static DoubleStreamdoubleStream(Spliterator.OfDouble spliterator, boolean parallel)Creates a new sequential or parallelDoubleStreamfrom aSpliterator.OfDouble.static IntStreamintStream(Supplier<? extends Spliterator.OfInt> supplier, int characteristics, boolean parallel)Creates a new sequential or parallelIntStreamfrom aSupplierofSpliterator.OfInt.static IntStreamintStream(Spliterator.OfInt spliterator, boolean parallel)Creates a new sequential or parallelIntStreamfrom aSpliterator.OfInt.static LongStreamlongStream(Supplier<? extends Spliterator.OfLong> supplier, int characteristics, boolean parallel)Creates a new sequential or parallelLongStreamfrom aSupplierofSpliterator.OfLong.static LongStreamlongStream(Spliterator.OfLong spliterator, boolean parallel)Creates a new sequential or parallelLongStreamfrom aSpliterator.OfLong.static <T> Stream<T>stream(Supplier<? extends Spliterator<T>> supplier, int characteristics, boolean parallel)Creates a new sequential or parallelStreamfrom aSupplierofSpliterator.static <T> Stream<T>stream(Spliterator<T> spliterator, boolean parallel)Creates a new sequential or parallelStreamfrom aSpliterator.
- 
Method Details- 
streamCreates a new sequential or parallelStreamfrom aSpliterator.The spliterator is only traversed, split, or queried for estimated size after the terminal operation of the stream pipeline commences. It is strongly recommended the spliterator report a characteristic of IMMUTABLEorCONCURRENT, or be late-binding. Otherwise,stream(java.util.function.Supplier, int, boolean)should be used to reduce the scope of potential interference with the source. See Non-Interference for more details.- Type Parameters:
- T- the type of stream elements
- Parameters:
- spliterator- a- Spliteratordescribing the stream elements
- parallel- if- truethen the returned stream is a parallel stream; if- falsethe returned stream is a sequential stream.
- Returns:
- a new sequential or parallel Stream
 
- 
streampublic static <T> Stream<T> stream(Supplier<? extends Spliterator<T>> supplier, int characteristics, boolean parallel)Creates a new sequential or parallelStreamfrom aSupplierofSpliterator.The Supplier.get()method will be invoked on the supplier no more than once, and only after the terminal operation of the stream pipeline commences.For spliterators that report a characteristic of IMMUTABLEorCONCURRENT, or that are late-binding, it is likely more efficient to usestream(java.util.Spliterator, boolean)instead.The use of a Supplierin this form provides a level of indirection that reduces the scope of potential interference with the source. Since the supplier is only invoked after the terminal operation commences, any modifications to the source up to the start of the terminal operation are reflected in the stream result. See Non-Interference for more details.- Type Parameters:
- T- the type of stream elements
- Parameters:
- supplier- a- Supplierof a- Spliterator
- characteristics- Spliterator characteristics of the supplied- Spliterator. The characteristics must be equal to- supplier.get().characteristics(), otherwise undefined behavior may occur when terminal operation commences.
- parallel- if- truethen the returned stream is a parallel stream; if- falsethe returned stream is a sequential stream.
- Returns:
- a new sequential or parallel Stream
- See Also:
- stream(java.util.Spliterator, boolean)
 
- 
intStreamCreates a new sequential or parallelIntStreamfrom aSpliterator.OfInt.The spliterator is only traversed, split, or queried for estimated size after the terminal operation of the stream pipeline commences. It is strongly recommended the spliterator report a characteristic of IMMUTABLEorCONCURRENT, or be late-binding. Otherwise,intStream(java.util.function.Supplier, int, boolean)should be used to reduce the scope of potential interference with the source. See Non-Interference for more details.- Parameters:
- spliterator- a- Spliterator.OfIntdescribing the stream elements
- parallel- if- truethen the returned stream is a parallel stream; if- falsethe returned stream is a sequential stream.
- Returns:
- a new sequential or parallel IntStream
 
- 
intStreampublic static IntStream intStream(Supplier<? extends Spliterator.OfInt> supplier, int characteristics, boolean parallel)Creates a new sequential or parallelIntStreamfrom aSupplierofSpliterator.OfInt.The Supplier.get()method will be invoked on the supplier no more than once, and only after the terminal operation of the stream pipeline commences.For spliterators that report a characteristic of IMMUTABLEorCONCURRENT, or that are late-binding, it is likely more efficient to useintStream(java.util.Spliterator.OfInt, boolean)instead.The use of a Supplierin this form provides a level of indirection that reduces the scope of potential interference with the source. Since the supplier is only invoked after the terminal operation commences, any modifications to the source up to the start of the terminal operation are reflected in the stream result. See Non-Interference for more details.- Parameters:
- supplier- a- Supplierof a- Spliterator.OfInt
- characteristics- Spliterator characteristics of the supplied- Spliterator.OfInt. The characteristics must be equal to- supplier.get().characteristics(), otherwise undefined behavior may occur when terminal operation commences.
- parallel- if- truethen the returned stream is a parallel stream; if- falsethe returned stream is a sequential stream.
- Returns:
- a new sequential or parallel IntStream
- See Also:
- intStream(java.util.Spliterator.OfInt, boolean)
 
- 
longStreamCreates a new sequential or parallelLongStreamfrom aSpliterator.OfLong.The spliterator is only traversed, split, or queried for estimated size after the terminal operation of the stream pipeline commences. It is strongly recommended the spliterator report a characteristic of IMMUTABLEorCONCURRENT, or be late-binding. Otherwise,longStream(java.util.function.Supplier, int, boolean)should be used to reduce the scope of potential interference with the source. See Non-Interference for more details.- Parameters:
- spliterator- a- Spliterator.OfLongdescribing the stream elements
- parallel- if- truethen the returned stream is a parallel stream; if- falsethe returned stream is a sequential stream.
- Returns:
- a new sequential or parallel LongStream
 
- 
longStreampublic static LongStream longStream(Supplier<? extends Spliterator.OfLong> supplier, int characteristics, boolean parallel)Creates a new sequential or parallelLongStreamfrom aSupplierofSpliterator.OfLong.The Supplier.get()method will be invoked on the supplier no more than once, and only after the terminal operation of the stream pipeline commences.For spliterators that report a characteristic of IMMUTABLEorCONCURRENT, or that are late-binding, it is likely more efficient to uselongStream(java.util.Spliterator.OfLong, boolean)instead.The use of a Supplierin this form provides a level of indirection that reduces the scope of potential interference with the source. Since the supplier is only invoked after the terminal operation commences, any modifications to the source up to the start of the terminal operation are reflected in the stream result. See Non-Interference for more details.- Parameters:
- supplier- a- Supplierof a- Spliterator.OfLong
- characteristics- Spliterator characteristics of the supplied- Spliterator.OfLong. The characteristics must be equal to- supplier.get().characteristics(), otherwise undefined behavior may occur when terminal operation commences.
- parallel- if- truethen the returned stream is a parallel stream; if- falsethe returned stream is a sequential stream.
- Returns:
- a new sequential or parallel LongStream
- See Also:
- longStream(java.util.Spliterator.OfLong, boolean)
 
- 
doubleStreamCreates a new sequential or parallelDoubleStreamfrom aSpliterator.OfDouble.The spliterator is only traversed, split, or queried for estimated size after the terminal operation of the stream pipeline commences. It is strongly recommended the spliterator report a characteristic of IMMUTABLEorCONCURRENT, or be late-binding. Otherwise,doubleStream(java.util.function.Supplier, int, boolean)should be used to reduce the scope of potential interference with the source. See Non-Interference for more details.- Parameters:
- spliterator- A- Spliterator.OfDoubledescribing the stream elements
- parallel- if- truethen the returned stream is a parallel stream; if- falsethe returned stream is a sequential stream.
- Returns:
- a new sequential or parallel DoubleStream
 
- 
doubleStreampublic static DoubleStream doubleStream(Supplier<? extends Spliterator.OfDouble> supplier, int characteristics, boolean parallel)Creates a new sequential or parallelDoubleStreamfrom aSupplierofSpliterator.OfDouble.The Supplier.get()method will be invoked on the supplier no more than once, and only after the terminal operation of the stream pipeline commences.For spliterators that report a characteristic of IMMUTABLEorCONCURRENT, or that are late-binding, it is likely more efficient to usedoubleStream(java.util.Spliterator.OfDouble, boolean)instead.The use of a Supplierin this form provides a level of indirection that reduces the scope of potential interference with the source. Since the supplier is only invoked after the terminal operation commences, any modifications to the source up to the start of the terminal operation are reflected in the stream result. See Non-Interference for more details.- Parameters:
- supplier- A- Supplierof a- Spliterator.OfDouble
- characteristics- Spliterator characteristics of the supplied- Spliterator.OfDouble. The characteristics must be equal to- supplier.get().characteristics(), otherwise undefined behavior may occur when terminal operation commences.
- parallel- if- truethen the returned stream is a parallel stream; if- falsethe returned stream is a sequential stream.
- Returns:
- a new sequential or parallel DoubleStream
- See Also:
- doubleStream(java.util.Spliterator.OfDouble, boolean)
 
 
-