Is there any way for reading two or more files in one Java8-stream?

前端 未结 3 1388
無奈伤痛
無奈伤痛 2021-01-02 21:52

I like new Java8 StreamAPI and want use it not only for one file. As usually, I use this code:

Stream lines = Files.lines(Paths.get(\"/somepat         


        
3条回答
  •  一生所求
    2021-01-02 22:32

    With cyclops-streams (a library we have created) you can write

      SequenceM.of("/somepathtofile1","/somepathtofile2")
                 .flatMapFile(File::new)
                 .forEach(System.out::println);
    

    Javadoc SequenceM extends java.util.stream.Stream (and also org.jooq.lambda.Seq) to add a lot of additional convenience methods.

提交回复
热议问题