// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.io.IOException;
import java.lang.reflect.Field;
import java.nio.file.FileStore;
import java.nio.file.Files;
import java.nio.file.Paths;

public class StorageDetailsWindows {
    public static String volType(String pathstr) {
        try {
            FileStore fs = Files.getFileStore(Paths.get(pathstr));
            Field vtf = fs.getClass().getDeclaredField("volType");
            vtf.setAccessible(true);
            int vt = vtf.getInt(fs);
            switch(vt) {
                case 2:
                    return "Removable";
                case 3:
                    return "Fixed";
                case 4:
                    return "Remote";
                case 5:
                    return "Optical";
                case 6:
                    return "RAMDisk";
                default:
                    return "Unknown";
            }
        } catch (NoSuchFieldException|SecurityException|IllegalArgumentException|IllegalAccessException|IOException e) {
            return "Undetermined";
        }
    }
    public static void main(String[] args) throws Exception {
        System.out.println(volType("C:\\"));
    }
}
