Java and File Search question

xhail

Limp Gawd
Joined
Jun 21, 2002
Messages
187
I am basically trying to write a program that will find a file when I start the program.

My program will work something like this:
I have 4 files that my program will try to search out on it's own. I already know the names of the files and all I need is the path in which these files are found. Is there an easy way to do this using the JAVA 1.5 API?

If there isn't an easy way of doing this, I would probably just write up a recursive search method or something. Any other suggestions?

Thanks
 
Do you know anything about where the file might be? If so that will help you a lot. If these files can be *anywhere* on the hard drive then you'll have to do what you mentioned, a recursive search over the entire filesystem.

Either way, you'll want to get very familiar with this API doc:
http://java.sun.com/j2se/1.5.0/docs/api/java/io/File.html

Good luck. Let us know what your solution is.
 
To be more specific, I'm trying to locate and load the bookmarks for Internet Explorer and Firefox in my application. So if I can somehow find out the Windows XP login name, I would be able to go to the directory and load up the file.

I know Firefox salts their installation directory with this random jumble of letters and numbers. For now, I'm thinking of using list() in the profiles directory to get and just going into the first folder that is returned. That folder should then have the file I'm looking for.

It's just I was wondering if there was a search method or something for the File API in JAVA.

Thanks for the link though :)
 
If your looking for the current users home dir MS Windows has aliases like :

Code:
"%USERPROFILE%\Local Settings"
equals "C:\Documents and Settings\CurrentUser\Local Settings" on my machine (MS Windows XP).
Code:
"%SystemRoot%\Temp"
equals "C:\WINDOWS\Temp" on my machine (MS Windows XP).

Maybe there's similar aliases on Linux, and other OS's.

Hope this helps a little :)

-E

 
Wow... that is exactly what I needed :)
That helps me out immensely!

Thank you!
 
Back
Top