Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java API to list volumes on windows

 
D Preethi
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Is there some java API which could list all the volumes available on a windows system? That is, suppose, I have C:\, D:\ volumes and there a Z:\ which is pointing to C:\abcd, is there a way to just get C:\ and D:\ listed? Or is there some API which can check if Z:\ is actually referring to some folder under C:\ only?


Thanks in advance,
Preethi
 
D Preethi
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And, just to add, I tried using File::listRoots but that returns all the drive letters i.e. C:\ , D:\ and Z:\ in the example I mentioned above.
 
Paul Clapham
Sheriff
Posts: 21319
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The listRoots method is there to provide a list of all of the drives, mapped or otherwise. And that's what it does. If you are unsatisfied with it, there isn't anything else.
 
Rob Spoor
Sheriff
Pie
Posts: 20608
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could check out FileSystemView. It has some utility methods like isDrive, isFileSystem etc. Check those out.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic