Stream builder() example
Description
Stream builder()
returns a builder for a Stream.
Syntax
builder
has the following syntax.
static <T> Stream.Builder<T> builder()
Example
The following example shows how to use builder
.
import java.util.stream.Stream;
//from w w w. j a va2s.c o m
public class Main {
public static void main(String[] args) {
Stream.Builder<String> b = Stream.builder();
b.accept("a");
Stream<String> s = b.build();
s.limit(10)
.forEach(System.out::println);
}
}