Wednesday, May 26, 2010

How to list out all system drives in your system



File.listRoots() will list out all the available file system roots / drives in your current system.

import java.io.File;

public class SysDrive {

     public static void main (String args[]) {
         
           File[] rootDrive = File.listRoots();
     
           for(File sysDrive : rootDrive){
               System.out.println("Drive : " + sysDrive);
           }
       }
}


1 comment:

  1. how to store all these drives in one variable . i want in my project

    ReplyDelete