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:>
Actually it will be very easy if you can divide the logic into different method
public Path readFile(File eachFile) {
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
//try-with-resources
try (Stream lines = reader.lines()) {
lines.forEach(System.out::println);
}
catch (IOException e) {
e.printStackTrace();
}
return eachFile.toPath();
}
And then call this method for each file
(1) Stream.generate(localFileProvider::getNextFile)
(2) .map(this::readFile) //process each file
(3) .forEach(path->Files.move(path,Paths.get("new path"))); //then move each file