How to list a 2 million files directory in java without having an “out of memory” exception

后端 未结 15 1759
挽巷
挽巷 2020-12-06 00:04

I have to deal with a directory of about 2 million xml\'s to be processed.

I\'ve already solved the processing distributing the work between machines and threads us

15条回答
  •  离开以前
    2020-12-06 00:37

    Since you're on Windows, it seems like you should have simply used ProcessBuilder to start something like "cmd /k dir /b target_directory", capture the output of that, and route it into a file. You can then process that file a line at a time, reading the file names out and dealing with them.

    Better late than never? ;)

提交回复
热议问题