好的,所以相信我,我想这样做是有原因的。也许不使用Java,但有。我可以使用 UNC 样式的路径原始访问 Windows 7 上的磁盘,例如:
RandomAccessFile raf = null;
try {
raf = new RandomAccessFile("\\\\.\\PhysicalDrive0","r");
byte [] block = new byte [2048];
raf.seek(0);
raf.readFully(block);
System.out.println("READ BYTES RAW:\n" + new String(block));
} catch (IOException ioe) {
System.out.println("File not found or access denied. Cause: " + ioe.getMessage());
return;
} finally {
try {
if (raf != null) raf.close();
System.out.println("Exiting...");
} catch (IOException ioe) {
System.out.println("That was bad.");
}
}
但是,如果我切换到“rw”模式,就会出现 NullPointerException,即使我以管理员身份运行程序,我也无法获得原始写入磁盘的句柄。我知道这已经被问过了,但主要是为了阅读……那么,写作呢?我需要 JNI 吗?如果是这样,有什么建议吗?
干杯