Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extract Drivename

Status
Not open for further replies.

Kostarsus

Programmer
Nov 30, 2000
86
DE
Hello,

Do exist a way to extract the drivename for a Windows-System in Java?

In hope of help
Kostarsus
 
java.io.File.getCanonicalPath() is a method that will return a full file path with the drive as the first letter, if you are on Windows.

but if you mean the path to the Windows directory
then
p= System.getProperty("windir");
or
p= System.getenv("windir") ;

would do it.
 
No, it does 't exactly what I mean.
If you open your explorer in Windows you can see the drive letter and the drive name of the partition. I search a function which will deliver the drivename of the partition, not the letter.

cu Kostarsus
 
Sounds like you should be writing your program in Visual C++ instead of Java...
 
Somebody had post me a solution in the Javaforum of Sun.
For everyone who is interested in this problem:

There is an abstract class in javax.swing.filechooser.FileSystemView.
Ths class has a method which is called: getSystemDisplayName(File f)
With this method you get the Drivename.

Whichever thanks for your replies.

cu Kostarsus
 
Yeah, that's great if you are developing a GUI app. Are you? You never mentioned this.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top