I'm having a little trouble in understanding how I can read and return the value of a certain offset position in a file.
For example, I know from my hex editor that the offset is D768, and the value is 32bit. So how can read this value and display it in a label.
Any help at all will be greatly appreciated.
I think that java.io.RandomAccessFile is your new friend :-)
Beware of the following code, it has not been tested.
RandomAccessFile raf = new RandomAccessFile("foo.bin", "r");
raf.seek(0xd768);
int value = raf.read();
Use the DataInputStream class. Open the file, and position it using skipBytes(offset), and then call readInt(). This will give you a 32 bit starting at the offset you used.
(Note that this assumes that the integer is represented in the file in with the most significant byte first.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With