I need to do some read-only processing on all files in a folder recursively. I use Files.walk to get the file stream, but I noticed that the api indicates that walk only returns a regular stream, not a parallel stream.
Files.walk
walk
How can I process all files in a directory in parallel?
You can convert any Stream to parallel Stream by calling Stream::parallel .
Stream
Stream::parallel
Stream<Path> stream = Files.walk(startPath).parallel().forEach(...);