I'm running into this nasty problem with Java on Windows. (Java on Linux does not have this problem.)
On Linux, as a root user, I can use new RandomAccessFile(new File("/dev/sdb"), "rw");
to both read AND write raw sectors of my 2nd drive.
On Windows, as an Administrator, I can use RandomAccessFile(new File("//./PhysicalDrive1"), "r");
to read raw sectors of an identical 2nd drive. However, if I specify the "rw"
mode instead, I get a java.io.FileNotFoundException
.
I can use JNI+C as a workaround on Windows but I'd like to have a non-DLL based cross-platform solution, based solely on Java.
Does anyone have any tips on how to solve this problem?
EDIT:
The exact exception that I get is about some 'parameter' being 'incorrect':
Exception in thread "main" java.io.FileNotFoundException: \\.\PhysicalDrive1 (The parameter is incorrect)
at java.io.RandomAccessFile.open(Native Method)
at java.io.RandomAccessFile.<init>(RandomAccessFile.java:241)
at java.io.RandomAccessFile.<init>(RandomAccessFile.java:122)
at MyTest.main(MyTest.java:100)