I have a pretty simple question.
How can I find the number of system-attached drives in Java?
Also, how can I determine if these are HDDs, SSDs, or USBs?
I have a pretty simple question.
How can I find the number of system-attached drives in Java?
Also, how can I determine if these are HDDs, SSDs, or USBs?
There is no system-independent way to tell the difference between, say, an HDD and an SDD, though you might be able to guess from the name of the drive. The best you can do is use FileSystemView:
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) );
System.out.println( "Type: " + fsv.getSystemTypeDescription( path ) );
System.out.println( "Is Drive? " + fsv.isDrive( path ) );
}