Thursday, October 05, 2006

Drive Names in Windows

Have you ever thought how to get drive letters in Windows? If you know the cool hack below, you wont need to struggle for that.


* @author karthikkannan
* Demo for listing drive letters on Windows
public class Utility {
public static void main(String[] args) {
File[] roots = getDrives();
for (File file : roots) {

public static File[] getDrives() {
return File.listRoots();

There is a static method called listRoots() in the class. Hope this was a useful tip. See you in the next post folks.


No comments: