我已经创建了源,流和接收器
源是整数源
流程将整数转换为字符串
接收器将写入文件
但是我不知道如何将所有这些连接在一起以获得可运行的图
public static void main(String[] args) {
ActorSystem system = ActorSystem.create();
Materializer materializer = ActorMaterializer.create(system);
Source<Integer, NotUsed> source = Source.range(0, 100);
Flow<Integer, ByteString, NotUsed> flow = Flow.fromFunction((i) -> {
return ByteString.fromString(i.toString());
});
Sink<ByteString, CompletionStage<IOResult>> sink = FileIO.toPath(Paths.get("love.txt"));
}
我将您的措辞集中在“可运行图”上。请仔细查看https://doc.akka.io/docs/akka/current/stream/stream-graphs.html#constructing-graphs,并在左侧使用Java作为您的编程语言,以获取正确的代码示例。此页面上是可运行的图形示例代码,它应有助于您将流式元素连接在一起。