* 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:
parent
6120b73918
commit
dcdaa5a0dd
4 changed files with 72 additions and 0 deletions
|
|
@ -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
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue