I have a binary file which consists of Delphi records. The record looks like:
TRMapFileHeader = record
FileType: String[8];
Points: Int64;
Objects: Int64;
Text: Int64;
ObjLayers: byte;
TextLayers: byte;
end;
I want to read this file in Java. I opened the file:
DataInputStream file = new DataInputStream(new FileInputStream(filename))
and then I've tried to read data:
for(int i = 0; i<8; i++)
System.out.print((char)file.readByte());
System.out.println();
System.out.println(file.readLong());
System.out.println(file.readLong());
System.out.println(file.readLong());
System.out.println(file.readByte());
System.out.println(file.readByte());
and I've got
instead of correct data which are:
RMF
441434
80457
14186
11
4
I played with different ways of reading and found out the next:
System.out.println(file.readByte());
for(int i = 0; i<3; i++)
System.out.print((char)file.readByte());
for(int i = 0; i<36; i++)
file.readByte();
System.out.println();
System.out.println(file.readByte());
System.out.println(file.readByte());
gives the next output: Eclipse output. First byte equals 3, then goes 3 characters, then 36 bytes and then last 2 parameters of record
So I'm wondering how to read this kind of records