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
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
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
To write the same 'k' after 1200 bytes:
f.seek(1200L);
f.writeLong(k[0]);
f.writeLong(k[1]);
;JOOP!
f.seek(1200L);
f.writeLong(k[0]);
f.writeLong(k[1]);
;JOOP!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks!
:)
http://java.sun.com/j2se/1.3/docs/guide/serialization/relnotes.html