GeeCON Prague 2014*
The moose likes Java in General and the fly likes Need some help. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "Need some help." Watch "Need some help." New topic
Author

Need some help.

Riddhi Joshi
Greenhorn

Joined: Dec 29, 2002
Posts: 21
Hello everyone,
I want to know any classes or methods in Java which helps me figure out the list of all the directories located in all the drives of the computer. Further, it should also give me the list of files in each directories.
I want the list of all the MS Office application exe's. They can be installed anywhere-on any drives of the computer. I have to figure this out for the further enhancements in my project that I am working on.
I hope I am making some sense.
Thanks.
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi Riddhi,
All you need is the good ole File class and some recursion to list every file on every drive on a machine. To begin you'll want to call the static listRoots() method which returns a File[] array. Try this:

That should list every file on the system. With some modifications you can manipulate the output in whatever manner you like.
Hope this helps,
Michael Morris


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Riddhi Joshi
Greenhorn

Joined: Dec 29, 2002
Posts: 21
Thank you so much for the code.
That really helped.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Need some help.