File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Need some help. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply 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.
 
 
subject: Need some help.
 
Threads others viewed
Question about MobileMe (.Mac)
How to get the list of drives & file Properties[urgent]
unexpected error in my seagate usb harddrive
Get file sharing.
what pattern(s) would you vote off the island?
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com