I want to know is there any way to list all local drives using java program. I want to create a software and in that I want a list of all local drivers so that I can click on it and select it. Please send me code that find all local drives.
I want to know is there any way to list all local drives using java program. I want to create a software and in that I want a list of all local drivers so that I can click on it and select it. Please send me code that find all local drives.
I think this code give you list of all drives-
Code:File []drives = new File("").listRoots(); for(int m=0;j<drives.length;m++) System.out.println(drives[m]);
This is a most easiest code to find all drives.Code:for(File drive : File.listRoots() ) System.out.println(drive);
It will help you.Code:File[] roots = File.listRoots(); for(int p=0;p<roots.length;p++) System.out.println("Root["+p+"]:" + roots[p]); System.out.println(drives[p]);
Bookmarks