Link to home
Start Free TrialLog in
Avatar of richardsimnett
richardsimnett

asked on

How do I create, read and write binary records to a file?

Hello,
This question is kinda basic, but it is something I cannot find any reference to do. I want to be able to create a record of a fixed size. Two Long integers stored in a record / class of some sort. Then I need to be able to write this data record by record to a binary file. I also need to know how to read this binary data back out of the file.

Please provide code examples.

Worth 500 points.

Rick
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

SOLUTION
Avatar of sciuriware
sciuriware

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
Avatar of sciuriware
sciuriware

To write the same 'k' after 1200 bytes:

    f.seek(1200L);
    f.writeLong(k[0]);
    f.writeLong(k[1]);

;JOOP!
ASKER CERTIFIED SOLUTION
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
Avatar of richardsimnett

ASKER

Thanks!