How can I get list all drives but also get the corresponding drive type (removable, local disk, or cd-rom, dvd-rom, etc)?
Right-click Computer > Manage > Storage > Disk Management, then right-click on the graphic of the drive that may be 'hidden' or 'unallocated' > Change Drive Letter/Paths... > select a letter from nearer the end of the alphabet > OK and the disk should show in Computer. Good luck. Was this reply helpful?
In Java, you use the File. listRoots() to list all the available drives of your computer. listRoots() is a static method in File class which return the array of available filesystem roots. To get the type of drive, you use the getSystemTypeDescription(File f) method of FileSystemView class.
Drive D:\ and External Drives can be found in File Explorer. Right click the Window icon on the bottom left and select File Explorer then click This PC. If Drive D:\ is not there, most probably you haven't partition your hard drive and to partition the Hard drive you can do that in Disk Management.
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)); }
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With