如何从java访问磁盘上的特定原始数据 [英] How to access specific raw data on disk from java

查看:96
本文介绍了如何从java访问磁盘上的特定原始数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下代码访问原始磁盘中偏移量为50字节的一个字节。

I'm trying to use the following code to access one byte with offset of 50 bytes in a raw disk.

randomAccessFile = new RandomAccessFile("C:", "r");
randomAccessFile.seek(50);
byte[] buffer = new byte[1];
randomAccessFile.read(buffer);

但我得到的是以下错误:

But all what I get is the following error:

java.io.FileNotFoundException: C: (Acceso denegado)
at java.io.RandomAccessFile.open(Native Method)
at java.io.RandomAccessFile.<init>(RandomAccessFile.java:212)
at java.io.RandomAccessFile.<init>(RandomAccessFile.java:98)
at pru.lseek.main(lseek.java:26)

有没有办法从java访问驱动器中的精确字节?

Is there any way to access a precise byte in a drive from java?

推荐答案

RandomAccessFile并不打算打开目录来操作条目,你需要创建或删除文件。 Acceso denegado可能意味着拒绝访问。
无论如何要做到这一点你需要JNI。

RandomAccessFile is not meant to open directories to manipulate entries, you need to create or remove files. "Acceso denegado" probably mean access denied. To do this anyway you need JNI.

编辑:你想做什么,真的很复杂,没有共同的方法可以做到这一点。你可以按扇区访问harddisc扇区,但是你必须解释它的结构,这显然取决于文件系统,FAT,NTFS,HPFS等。

What you are trying to do, is really complicated, there is no common way to do that. You can access the harddisc sector by sector, but then you would have to interpret it's structure, which obviously depends on the file system, FAT,NTFS,HPFS etc.

这篇关于如何从java访问磁盘上的特定原始数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆