How can I get list of all drives but also get the corresponding drive type (removable,local disk, or cd-rom,dvd-rom... etc)?
How can I get list all drives but also get the corresponding drive type (removable, local disk, or cd-rom, dvd-rom, etc)?
Solution 1:
With this code you can get all drives and its type description
File[] paths;
FileSystemView fsv = FileSystemView.getFileSystemView();
// returns pathnames for files and directory
paths = File.listRoots();
// for each pathname in pathname array
for(File path:paths)
{
// prints file and directory paths
System.out.println("Drive Name: "+path);
System.out.println("Description: "+fsv.getSystemTypeDescription(path));
}
Solution 2:
Assuming it's windows, use File.listRoots()
to get all roots.
Then use FileSystemView
to check whether it's floppy disk or a drive. Other than that I have no idea.