My Application has two files:
1. An image file and
2. A
Java Object that is written(persisted) to another file.
I wish to create a single file by combining these two files. And then, (later) re-create the image and the object from this single file.
So, I create a FileOutputStream and first write the image to it followed by the object.Something like:
I am able to create this new file using the above mentioned approach. The problem is in reading the file back and recreating things. I want to re-create/construct both the object and the image but the stream is corrupted.
Can I do some sort of demarcation in the file that can distinguish the image data and object data? Is there any other approach that I can use? I can't afford to save the two resources in separate files(user might delete one of them and thereby render the other useless). If nothing works out, I might save them in separate files and then zip them to get a single file.
Please advice.
Thanks.