How to read binary data



Hi,

I have to use Java to read a binary file. This looks easy (yes, I've
read the tutorial on Sun's website). The problem is that the files
were created by a C program. I don't know the exact file format, but I
have the C source code.

The first entry is grabbed like that:

fread(query_length, sizeof(long), 1, file)

Since query_length is a pointer to something of type long (four-byte
signed integer), I expect that this in Java should be:
int seqLen = myDataInputStream.readInt();

.... but unfortunately it does not work. I am getting 172777843 instead
of 56.

Does anybody have an idea what I am doing wrong? Maybe some ideas for
reverse engineering? As I said, I don't know the file format, but I
have a working C code (including source) that I may use to encode my
own data.

Best regards,
James
.



Relevant Pages

  • common source for java & J#
    ... I've created a website at http://www.gotjsharp.com for issues on using ... one set of source code for java and J#. ... Prev by Date: ...
    (microsoft.public.dotnet.vjsharp)
  • Re: How to read binary data
    ... I have to use Java to read a binary file. ... read the tutorial on Sun's website). ... have the C source code. ... As I said, I don't know the file format, but I ...
    (comp.lang.java.programmer)
  • Re: Something has to be tested and maintained was Re: GoTo in Java
    ... I am on record as saying that maintenance of source code is self defeating. ... every module or program when new functionality is added. ... is that a brick is a brick; it has the attributes and behaviours of a brick. ... to translate it to Java, and get something not too bad. ...
    (comp.lang.cobol)
  • Re: GoTo in Java
    ... >> to translate it to Java, and get something not too bad. ... > your 'cleaned up' Java now works the same as the Fortran code. ... NOT maintain source code. ... Encapsulate functionality and reuse it. ...
    (comp.lang.cobol)
  • Something has to be tested and maintained was Re: GoTo in Java
    ... to translate it to Java, and get something not too bad. ... Source code translations have been tried for several decades and they ... Because of its COBOL and procedural programming roots, ... Encapsulate functionality and reuse it. ...
    (comp.lang.cobol)