1

我想读取连接到安卓平板电脑的 USB 闪存的第一个扇区或第一个字节!

我知道应该使用 RandomAccessFile,但我不知道我的 USB 闪存的地址是什么!

感谢您的帮助


我找到了这段代码,但我不知道应该放什么来代替 args[0]

public class FAT16
{
public static void main(String[] args) throws IOException
{
// open file whose name is on the command line for input

RandomAccessFile file = new RandomAccessFile(args[0], "r");

// skip ahead to byte 19 (0x13 hex) where the num of sectors is stored

file.seek(0x13);

// 2-byte values are little-endian; Java is big-endian, so we
// have to read the two bytes separately and glue them together
// ourselves

int low = file.readUnsignedByte();
int high = file.readUnsignedByte();

int sectorsOnDisk = low + (high * 256);

// skip ahead to where the sectors per FAT is stored

file.seek(0x16);
low = file.readUnsignedByte();
high = file.readUnsignedByte();

int sectorsPerFAT = low + high * 256;

// skip back to where the bytes per sector is stored

file.seek(0x0b);
low = file.readUnsignedByte();
high = file.readUnsignedByte();
int bytesPerSector = low + high * 256;

// report size of disk and number of sectors per FAT

System.out.println("Disk size = " + sectorsOnDisk * bytesPerSector );
System.out.println("Sectors per FAT = " + sectorsPerFAT);
}

}

我知道我们应该在 linux 中使用“/dev/sdaX”,但是对于 adnroid 会是什么?

4

1 回答 1

1

Android SDK 中不支持“USB 闪存”。请咨询您的设备制造商,了解他们是否有特定协议可在其设备上访问“USB 闪存”。

于 2012-01-31T15:38:35.677 回答