I am trying to create a javadsl Flow which processes Path elements. It should emit the lines of content of the file associated with the Path element. In other words, I think I need to flatten the stream of Path elements to a stream of String elements.
A Flow does have a flatten method but it involves using a FlattenStrategy and I am unsure on how to use it for my case.
final Flow<Path, String, BoxedUnit> toFileLines = Flow
.<Path>create()
.flatten(FlattenStrategy.
Any help is greatly appreciated!
Edit1: So it has come to my understanding that it might be a good idea to read the file with a StreamReader and emit a new String whenever the reader reaches a '\n'. So the question now is how to emit multiple elements from a single transformation method. Like so
final Flow<Path, String, BoxedUnit> toFileLines = Flow
.<Path>create()
.mapAsync(
//create streamreader
//while streamreader has.next
//read line until \n
//emit line
);
Is this possible?
SynchronousFileSource
. 2.) will be much easier with the upcoming RC4 which will include components for splitting string streams: github.com/akka/akka/pull/17446/files – jrudolph