0

If I have a java path such as "/users/james/.myapp/" can I figure out the physical drive name (ie. \\.\PHYSICALDRIVE0) using just java apis?

I thought this might be possible because you can reference a physical drive in java:

new RandomAccessFile("\\\\.\\PhysicalDrive0", "r");

simgineer
  • 1,754
  • 2
  • 22
  • 49
  • [`File.listRoots()`](https://docs.oracle.com/javase/8/docs/api/java/io/File.html#listRoots--). – Elliott Frisch Dec 19 '16 at 01:27
  • @Elliott That gets me the letter for example "C:\ D:\". Is there a way to get the physical drive name from that? – simgineer Dec 19 '16 at 01:33
  • Actually it appears that you can even though I'm not going to try and do it. I'm just going to look up the drive's model number using wmic. The answer to this question shows an example of reading from a physical drive using a random access file: http://stackoverflow.com/questions/22161967/accessing-windows-disks-directly-with-java-nio – simgineer Dec 19 '16 at 01:38
  • Then the answer is No. Not in Java. The simplest solution will be to use an external window application to map the path to a physical drive. – Stephen C Dec 19 '16 at 01:39
  • Sigh. That is a bummer. I'd like to get a drive's model number but the only way i can figure out to do this is currently without too much work is powershell but I think i need administrative rights to run powershell and I'd like my utility to be able to work without that. http://stackoverflow.com/questions/31088930/combine-get-disk-info-and-logicaldisk-info-in-powershell – simgineer Dec 19 '16 at 01:44

1 Answers1

1

If you need a solution to check a drive model number into Windows, you can try to read this through Windows Registry, some useful doc can be found here :read/write to Windows Registry

Current drives can be found in HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices

Community
  • 1
  • 1
Xephi
  • 431
  • 2
  • 9