How can I get list all drives but also get the corresponding drive type (removable,local disk, or cd-rom,dvd-rom... etc)?
This code snippet works on Windows. It correctly reports USB pen drives as removable, but on my laptop a USB hard drive is marked as non removable. Anyway this is the best I found without using native code.
for (Path root : FileSystems.getDefault().getRootDirectories()) {
FileStore fileStore = Files.getFileStore(root);
System.out.format("%s\t%s\n", root, fileStore.getAttribute("volume:isRemovable"));
}
Source: this file that apparently comes from the JDK