Example for Source.fromIterator #25468 (#28582)

* add example for Source.fromIterator #25468

* scala fmt code style fix

* don't use test as a sample for docs
This commit is contained in:
Evgeny Sidorov 2020-02-11 16:58:00 +03:00 committed by GitHub
parent 6120b73918
commit dcdaa5a0dd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 72 additions and 0 deletions

View file

@ -0,0 +1,26 @@
/*
* Copyright (C) 2020 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.stream.operators.source;
import akka.actor.ActorSystem;
import akka.stream.javadsl.Source;
import java.util.Arrays;
public class From {
private ActorSystem system = null;
void fromIteratorSample() {
// #from-iterator
Source.fromIterator(() -> Arrays.asList(1, 2, 3).iterator())
.runForeach(System.out::println, system);
// could print
// 1
// 2
// 3
// #from-iterator
}
}