How can I get list all drives but also get the corresponding drive type (removable, local disk, or cd-rom, dvd-rom, etc)?
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)); }
1.4m articles
1.4m replys
5 comments
57.0k users