Streaming files and moving them after read

后端 未结 4 639
心在旅途
心在旅途 2021-02-02 12:24

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:

4条回答
  •  没有蜡笔的小新
    2021-02-02 13:04

    I would just create two methods:

    public void processFile(File f);
    public void moveFile(File f, File dstFolder);
    

    then in lambda:

    Stream.generate(localFileProvider::getNextFile).forEach(file->
       {
         processFile(file);
         moveFile(file, dstFolder)
       }
    }
    

提交回复
热议问题