Saturday, April 28, 2012

How to list the system roots (very useful for Windows)


Have you ever need to get all root of your system (C:/, D:/, E:/ etc) ? It is very simple with the below code:

...
File[] roots = File.listRoots();
for (File root : roots) {
   System.out.println(root);
}
...

Possible output:

C:\
D:\
E:\

No comments:

Post a Comment