1

I searched a lot about it but i don't found anything. I have a file from `File f = File.getRoots().get(0);` and i would test if this drive is an SSD or an HDD.

Is this possible? Here is some pseudocode that you can see what i need it for:

File f = myFile.getRoot();
if(isSSD(f)){
     System.out("We will write to SSD are you sure?");
}

If someone knows how to write the public static isSSD(File f) method please help.

I know there is NO cross platform solution so i think i need one for linux mac and windows:

if(System.getProperty("os.name").contains("Windows")){
    //The code for Win
}else if(System.getProperty("os.name").contains("UNIX")){
    //The code for linux
}else if(System.getProperty("os.name").contains("Mac")){
    //The code for mac
}

Gratefull for Answers.

Niton
  • 189
  • 4
  • 16

1 Answers1

2

There are ways for each OS, but not in native Java, so it will probably require some time to adapt to Java (JNI calls etc.). For example:

Alternatively, you could run a benchmark and check if sequential reads and random reads have similar performance (SSD) or not (HDD). You will need to take caching into account etc.

Community
  • 1
  • 1
assylias
  • 321,522
  • 82
  • 660
  • 783