Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need some help.

 
Riddhi Joshi
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Riddhi Joshi
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you so much for the code.
That really helped.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic