I have a scenario where I have to loop through file contents for multiple purposes. My question here is, is it Ok to call file.listFiles() multiple times? Is this an expensive operation? Or should I store this this into a variable and use it in all the places?
The problem here is. I may have 3 or 4 levels. In each level, I have to validate or carry some logics. I have to start from the folder 1 and do logic 1 till folder 4. Then again I have to start from folder 1 to perform logic 2 and then for logic 3 and so on.
Folder 1
 - Folder 2
 - File1
      - Folder 3
      - File2
           - Folder 4
           - File3
 
     
     
     
     
    