I was trying to automate some of my manual work, I came across one problem. Is java providing any option by which if I give the file name and directory name it will go ahead and search that file in the given directory or sub-directory and return me the complete path of the file ? Unfortunately not :(, there is no direct API that can do this work for me. But Kannan told me that one can make a code which can recursively do this work. And he already had written some code for this. I was trying to tackle this problem with a different approach. The approach is something like:
On windows, dos gives me an option to search a file in a dir or sub-dir by command:
dir filename /s
Linux and Solaris gives me option of search the same by command: find /directory_name filename
So, why not using the runtime option of java system class and write a code like:
if ( OS == Windows) {get it by dir filename /s}
elseif (OS == Linux or Solaris or Unix){get it by find /directory_name filename}
else {God Knows only :)}
Right now I am not ready with code(because this dos is not giving anything directly, so need to remove useless things) but will come back soon with the results and the optimal code. Any suggestions are most welcome.