Maranellas
asked on
How to detect system drive using JAVA
As the topic says.I need short function to detect system drive letter.
ASKER
I don't need to get list of drives.I need to get main drive where windows installed.
try the following code
String systemDrive = System.getProperty("System Drive");
see the following link for reference
http://www.bigresource.com/Tracker/Track-vb-NkqegKV5n3/
http://leepoint.net/notes-java/io/30properties_and_preferences/40sysprops/10sysprop.html
String systemDrive = System.getProperty("System
see the following link for reference
http://www.bigresource.com/Tracker/Track-vb-NkqegKV5n3/
http://leepoint.net/notes-java/io/30properties_and_preferences/40sysprops/10sysprop.html
Another approach:
System.out.println(System. getPropert y("user.ho me").charA t(0));
Assuming the user home directory is always an the windows drive.
System.out.println(System.
Assuming the user home directory is always an the windows drive.
ASKER
okay when i try
String systemDrive = System.getProperty("System Drive");
i get NULL response
and when i try System.out.println(System. getPropert y("user.ho me").charA t(0));
i get the following error
found : char
required: java.lang.String
private String drv = System.getProperty("user.h ome").char At(0);
but java.lang package is imported already
String systemDrive = System.getProperty("System
i get NULL response
and when i try System.out.println(System.
i get the following error
found : char
required: java.lang.String
private String drv = System.getProperty("user.h
but java.lang package is imported already
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
File[] roots = File.listRoots();
to get the list of drives on your system