I have a series of objects which write their data out to a file via DataOutputStream.
As my application file format evolves, I will be adding further data objects to it, which should be able to be read by "older" versions of the application.
To be able to do this, I am needing to preface the objects data with a size value indicating the number of bytes that the current object will take up.
However, as this data can be a variable size, notably when handling strings, I cannot know beforehand what the size will be.
Is there a way to "pre-write" to a byte buffer, as if it were a DataOutputStream (methods in particular - writeByte, writeShort, writeInt, writeUTF) which will enable me to get back the byte length of the data before writing it out to the DataOutputStream ? Doing this will enable me to skip over newer data objects that older versions of the application does understand.