I am in the process of writing a simple java program that reads the contents of a directory and print the file names and last modified time.
The problem I'm looking at is the repository I'm reading is quite huge, and there are some cases where files in the same directory can exceed 20,000. Using the api file
`file.listFiles()`
will start the creation of 20,000 file objects, my problem in this may slow down the process, memory may also swell
Is there a way to do ie to tell java to scan the directory 50 files at a time or at least repeat one file at a time, instead of loading all the objects in memory at once.
source
share