Close

Java 8 Stream operations cheat sheet

[Last Updated: Apr 30, 2017]



Stream operations




Obtaining a Stream
Intermediate Operation
Terminal Operations
Collection
stream()
parallelStream()

Stream
IntStream
LongStream
DoubleStream
static generate()Unordered
static of(..)
static empty()
static iterate(..)
static concat(..)
static builder()

IntStream
LongStream
static range(..)
static rangeClosed(..)

Arrays
static stream(..)

BufferedReader
lines(..)

Files
static lines(..)
static list(..)
static walk(..)
static find(..)

JarFile
stream()

ZipFile
stream()

Pattern
splitAsStream(..)

SplittableRandom
ints(..)Unordered
longs(..)Unordered
doubles(..)Unordered

Random
ints(..)
longs(..)
doubles(..)

ThreadLocalRandom
ints()
longs(..)
doubles(..)

BitSet
stream()

CharSequence (String)
IntStream chars()
IntStream codePoints()

StreamSupport (low level)
static doubleStream(..)
static intStream(..)
static longStream(..)
static stream(..)
BaseStream
sequential()
parallel()
unordered()
onClose(..)

Stream
filter(..)
map(..)
mapToInt(..)
mapToLong(..)
mapToDouble(..)
flatMap(..)
flatMapToInt(..)
flatMapToLong(..)
flatMapToDouble(..)
distinct()stateful
sorted(..)stateful
peek(..)
limit(..)stateful,
               short-circuiting
skip(..)stateful

IntStream, LongStream and DoubleStream have similar methods as Stream
 does but with different args.
 
Here are some extra methods:
IntStream mapToObj(..) asLongStream() asDoubleStream() boxed() LongStream mapToObj(..) asDoubleStream() boxed() DoubleStream mapToObj(..) boxed()
BaseStream
iterator()
spliterator()

Stream
forEach(..)
forEachOrdered(..)
toArray(..)
reduce(..)
collect(..)
min(..)
max(..)
count()
anyMatch(..)short-circuiting
allMatch(..)short-circuiting
noneMatch(..)short-circuiting
findFirst()short-circuiting
findAny()short-circuiting,
               nondeterministic

IntStream, LongStream and DoubleStream have similar methods as Stream
 does but with different args.
 
Here are some extra methods:
IntStream LongStream DoubleStream sum() average() summaryStatistics()

See Also