I want to stream the lines contained in files but MOVING each file to another folder once it has been processed.
The current process is like this:
Explanation:
- I create a
StreamofFiles - I create a
BufferedReaderfor each one of them - I
flatMapto the linesStreamof theBufferedReader - I print each line.
Code (omitted exceptions for simplicity):
(1) Stream.generate(localFileProvider::getNextFile)
(2) .map(file -> new BufferedReader(new InputStreamReader(new FileInputStream(file))))
(3) .flatMap(BufferedReader::lines)
(4) .map(System.out::println)
.MOVE_EACH_FILE_FROM_INPUT_FOLDER_TO_SOME_OTHER_FOLDER;
Would it be possible to move each file once it has been completely read and continue processing the other files in the stream?