How to read all lines of a file in parallel in Java 8

前端 未结 1 1207
庸人自扰
庸人自扰 2020-12-06 00:35

I want to read all lines of a 1 GB large file as fast as possible into a Stream. Currently I\'m using Files(path).lines() for that. A

相关标签:
1条回答
  • 2020-12-06 01:18

    You might find some help from this post. Trying to parallelize the actual reading of a file is probably barking up the wrong tree, as the biggest slowdown will be your file system (even on an SSD).

    If you set up a file channel in memory, you should be able to process the data in parallel from there with great speed, but chances are you won't need it as you'll see a huge speed increase.

    0 讨论(0)
提交回复
热议问题