Link to home
Start Free TrialLog in
Avatar of wau
wau

asked on

binary struct reading from file. How to?

I have a file written from MSVC++ 6.0 like:

typedef struct My_format{
short num_1;
char name_1[4];
short num_2;
char name_2[10];
}My_format;
This structure repeats every 256 bytes.
I have to read this from Java. The only class that has readShort() method is RandomAccessFile. Do I have to read the members of the struct one by one? Or is there any method to do buffered reading?
If I read in an array of bytes, how can I convert the corresponding bytes to short/char[] ?

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of imladris
imladris
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial