This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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.
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
Joined: Dec 29, 2002
Thank you so much for the code. That really helped.