André L. S. Softwares Development, Technology and Games

24May/091

Retrieving hard drives or removable devices

You've tried retrieve the hard drives or removable devices using java.io.File and passed "/" like parameter in class constructor? The result is the root of classpath, isn't?

To obtain the hard drives or removable devices, use File.listRoots(). This code return a File array, where each index of array is a removable device or hard disk unit.

Follow this sample:

File[] units = File.listRoots();

for(File unit : units){
    System.out.println(unit.getAbsolutePath());
}
Tagged as: , Leave a comment
Comments (1) Trackbacks (0)

Leave a comment


No trackbacks yet.