Hi, i am creating program that gets 'key' string and directory path and finds if key string is present in any file under given path,
everything seemed OK but when i put path like "/" after 5 mins i get error : Too many opened files. I've minimalized opened File object at the same time as much as posible, tried to call System.gc(),tried to close every stream every opened file, google but i still cannot search in bigger directories.
Algorithm (mine one is much bigger so i tried to make it as small as possible:
read 'path';
read 'key'(set as public);
#&
call method get('path') {
#&
String[] files = all files in 'path' directory;
for(String s : files) {
if File('path' + s).isDirectory() call again method get: get(path + "/" + s); //Searching in subdirectories
if File('path' + s).isFile() open it and search if 'key' is there -if yes
write file;
#&
}
}
#& - where i tried System.gc()
Anyone has some idea why I always get that runtime error ?
(I need it to search hundreds of GB so when my 40GB partition do this what will bigger one do
)