0
junk.writeBytes("Henry McCollum");
junk.writeInt = 9304029494;
junk.writeBytes("Toronto");

If the above example were all ints, I could just set the record size to be equal to 12(since 3 ints * 4 bytes = 12), but how would I know how big the 2 string are for name and city?

TheEyesHaveIt
  • 980
  • 5
  • 16
  • 33

1 Answers1

1

You would need to record the size of the string:

junk.writeInt("Henry McCollum".length());
junk.writeBytes("Henry McCollum");
//and so on

When reading read the int and then the correct number of bytes specified by that int.

nanofarad
  • 40,330
  • 4
  • 86
  • 117