I want to write a Header Object (POJO implementing Serializable interface) at the TOP of the file before writting anything (Serialized Objects) to this file. and want to update the same header object when all other objects are being written to the file.
For this i am trying to use a specific Byte Block. But when i get the byte from ByteArrayOutputStream it creates a new byte array with the size of the object in bytes.
eg. i have a header object which is almost 197 bytes in size (just a rough estimate with some testing) and i want to write this header object at TOP by allocating 300 bytes to it. so that i can start writting all other objects after 300 bytes in file.
code snippet is as follows:
Questions: 1. How we can write any object in serialized form with specific byte size? 2. How can we update that object again with new data, before closing the file or on some condition?
Can someone please guide me , how this can be done, so that before reading file contents, i can actually go to the top and read header object in the begining to get file information.
-------------------------------<br />you can't move ahead, unless you try for it.