Re: Another topic on how to read a binary file.
Knitter wrote:
I have a binary file, the Ant Movie Catalog database if anyone knows
the software. It is a file where information about movies is stores,
the software was created in Delphi so the binary files contains Pascal
strings and integers.
I know the file format, for example, I know that the strings are store
using a 4 bytes integer representing the string length, followed by
the actually string. What I'm falling to understand is how to read the
file.
I've been using BufferedInputStream created with a FileInputStream.
If I use the read(byte[]) method, that fills the passed array with the
array.lenght how can I transform that array of bytes into the integer
that I need?
So I thought of reading the 4 byte that tells me how long each string
is, convert the array with the 4 bytes into the needed integer and
then reading the string into another array with the size of the
integer I have found.
I'm stuck with how to correctly read the file, how to convert the
bytes into integers.
If you wrap your stream in a BinaryReader you will get some
convenient methods.
Arne