How to find number of drives in Java
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Lun_Xiao
Posted On:   Wednesday, February 27, 2002 03:29 PM


Hi,
How can I find out how many drives on
my machine in a Java application?

Thanks.

Re: How to find number of drives in Java

Posted By:   Heinrich_Soebke  
Posted On:   Friday, March 1, 2002 12:20 AM

Hi Lun,


perhaps this is a answer for your question:

use the method File.listRoots()


private static void showRoots() throws IOException {
File[] roots = File.listRoots();

for (int counter=0; counter< roots.length; counter++) {
File thisRoot = roots[counter];
System.out.println(counter + "*---*" + counter);
}
}

private static void dumpFile(File pFile) throws IOException {
System.out.println("--> absolutePath:<" + pFile.getAbsolutePath()+ ">");
try {
System.out.println("--> canonicalPath:<" + pFile.getCanonicalPath()+ ">");
} catch (IOException ioe) {
System.out.println("--> canonicalPath:<" + ioe+ ">");
}
System.out.println("--> getName:<" + pFile.getName()+ ">");
System.out.println("--> getParent():<" + pFile.getParent()+ ">");
System.out.println("--> getPath():<" + pFile.getPath()+ ">");
}
About | Sitemap | Contact