In my app i need to serialize an array of a custom collection type:
IntList[] collections; // need to be serialized
Due to the nature of the coding environment we're using, i cannot rely on 3rd party or any Java built-in packages for doing the serialization and have to perform it all myself.
The best way i could come up with is to store it all in a big byte array, encoding the length of each element before serializing it.
for example, for an array of collections that looks like this:
| 0 | (1, 6, 3, 7)
| 1 | (7, 2, 4, 6)
| 2 | ( 1 )
Would be serialized as:
4 (length of collection at 0) followed by the elements
4 (length of collection at 1) followed by the elements
1 (length of collection at 2) followed by the elements
Is there a better option that would optimize data sizes needed for serialization?