I have a working tree which is the following:
Root
├─Site1
| ├─file.def
| ├─subfolder1
| └─subfolder2
├─Site2
| ├─file.def
| ├─subfolder1
| └─subfolder2
└─Site3
└...
there are thousands of files contained in the subfolders. Now, I want to read the file.def, which contains data about site's subfolders and then open the subfolders according to said data. I'm pretty sure there is a better way to do that but here's my solution:
Collection<File> DefFiles = FileUtils.listFiles("C:/Root", acceptmapDef, true); //listFiles Accepting def files only
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 a JSONObject from the correspondance between the def file
// and the html files found in the subfolders
}
}
Now, when I run my script on unix, after some time the process obviously crashes and the "too many files open" exception is thrown. IMO, the fact that the script reads all the files twice is a problem, but since I'm new to fileUtils, that's the only way I found. Any idea would be appreciated