I'm using this code to read all folders in proc filesystem
for (Path processPath :
Files.newDirectoryStream(FileSystems.getDefault().getPath("/proc"), "[0-9]*"))
{
// Some logic
}
After some time I get this error
java.nio.file.FileSystemException: /proc: Too many open files
Looks like this loop is opening files without closing them. Is there any way to close the file after each cycle run?