How do I list all drives/filesystem roots on my system?

Davanum Srinivas

The listRoots() method of the File class was introduced with the 1.2 release for this:

File[] roots = File.listRoots();
for(int i=0;i<roots.length;i++)
    System.out.println("Root["+i+"]:" + roots[i]);
0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.