Java Utililty Methods Stream of

List of utility methods to do Stream of

Description

The list of methods to do Stream of are organized into topic(s).

Method

StreamtoStream(Iterator iter, boolean parallel)
to Stream
return StreamSupport.stream(Spliterators.spliteratorUnknownSize(iter, Spliterator.ORDERED), parallel);
StreamtoStream(Optional value)
No longer needed in Java 9 where Optional.stream() is added.
if (value.isPresent()) {
    return Stream.of(value.get());
} else {
    return Stream.empty();
StreamtoStream(T[] array, boolean parallel)
to Stream
return StreamSupport.stream(Arrays.spliterator(array), parallel);
StreamtoStreamLine(final Scanner scanner)
to Stream Line
Objects.requireNonNull(scanner);
final Iterator<String> iter = new Iterator<String>() {
    final Scanner s = scanner;
    @Override
    public boolean hasNext() {
        return s.hasNextLine();
    @Override
...
StreamtoStreamNumber(final Scanner scanner)
to Stream Number
Objects.requireNonNull(scanner);
final Iterator<Long> iter = new Iterator<Long>() {
    final Scanner s = scanner;
    @Override
    public boolean hasNext() {
        boolean hasNumber = false;
        while (s.hasNext()) {
            hasNumber = s.hasNextLong();
...