Java 8 Stream with batch processing

前端 未结 15 916
醉梦人生
醉梦人生 2020-11-28 02:42

I have a large file that contains a list of items.

I would like to create a batch of items, make an HTTP request with this batch (all of the items are needed as par

15条回答
  •  误落风尘
    2020-11-28 03:08

    It could be easily done using Reactor:

    Flux.fromStream(fileReader.lines().onClose(() -> safeClose(fileReader)))
                .map(line -> someProcessingOfSingleLine(line))
                .buffer(BUFFER_SIZE)
                .subscribe(apiService::makeHttpRequest);
    

提交回复
热议问题