How to read binary data
- From: Dominik G <tnorgd@xxxxxxxxx>
- Date: Thu, 25 Jun 2009 17:46:07 -0700 (PDT)
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
.
- Follow-Ups:
- Re: How to read binary data
- From: markspace
- Re: How to read binary data
- From: Roedy Green
- Re: How to read binary data
- From: Roedy Green
- Re: How to read binary data
- From: Joshua Cranmer
- Re: How to read binary data
- From: Peter Duniho
- Re: How to read binary data
- From: Eric Sosman
- Re: How to read binary data
- Prev by Date: Re: Why are methods of java.util.concurrent classes final?
- Next by Date: Re: How to read binary data
- Previous by thread: Java Goldmine major update: http://javagoldmine.uuuq.com http://javagoldmine.by.ru http://tarkus01.by.ru
- Next by thread: Re: How to read binary data
- Index(es):
Relevant Pages
|