Deeply Search Files In Given Directory Java - Recursive Way
For one of my Java projects I need to search files and directories within given directory, so i need to come up with optimal solution cause when i searched a little for this problem the codes floating around are just useless some of them not searching in a deep way or some of them are written in a poor way. So I come up with my own solution that do the job with recursive way. Here is a code for that.
public void deepRecSearch( File givenDir ) throws IOException {
if (givenDir.isDirectory()) {
final File[] childs = givenDir.listFiles();
for( File child : childs ) {
deepRecSearch(child);
}
return;
}
//put your implementation about file here
//like what you wanna do with that file print absolutePath or sth
}
