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

后端 未结 15 1776
挽巷
挽巷 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:15

    If file names follow certain rules, you can use File.list(filter) instead of File.listFiles to get manageable portions of file listing.

提交回复
热议问题