Вопрос

I hava a binary file like this :

offset | size/type | Description
-------+-----------+-----------------------------------------------------------
0x0000 | 28 chars  | zero terminated string
0x001c |  1 dword  | fileoffset of first compressed data block (header size)
0x0020 |  1 dword  | overall size of compressed file

I can read the 28 chars as a String. But I don't know how to read a dword and store it as an int.

Это было полезно?

Решение

DataInputStream.readFully() and .readInt(). You may have to do something about the (unspecified) byte order though. If that's an issue, ByteBuffer.getInt(), after setting the appropriate byte order.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top