Using java Fileutils.listfiles on large directories UNIX -
i have working tree following:
root ├─site1 | ├─file.def | ├─subfolder1 | └─subfolder2 ├─site2 | ├─file.def | ├─subfolder1 | └─subfolder2 └─site3 └...
there thousands of files contained in subfolders. now, want read file.def, contains data site's subfolders , open subfolders according said data. i'm pretty sure there better way here's solution:
collection<file> deffiles = fileutils.listfiles("c:/root", acceptmapdef, true); //listfiles accepting def files collection<file> otherfiles = fileutils.listfiles("c:/root"), acceptmapothers, true); //listfiles accepting every other file for(files def: deffiles){ // read def file for(files file: otherfiles){ // creates jsonobject correspondance between def file // , html files found in subfolders } }
now, when run script on unix, after time process crashes , "too many files open" exception thrown. imo, fact script reads files twice problem, since i'm new fileutils, that's way found. idea appreciated
wiki
Comments
Post a Comment