This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes java API to list volumes on windows Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "java API to list volumes on windows" Watch "java API to list volumes on windows" New topic
Author

java API to list volumes on windows

D Preethi
Ranch Hand

Joined: May 24, 2008
Posts: 68
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

Joined: May 24, 2008
Posts: 68
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
Bartender

Joined: Oct 14, 2005
Posts: 18712
    
    8

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

Joined: Oct 27, 2005
Posts: 19725
    
  20

You could check out FileSystemView. It has some utility methods like isDrive, isFileSystem etc. Check those out.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java API to list volumes on windows