Re: Accessing serialized objects randomly
Tuesday, July 19, 2005 01:56 AM
For Random access what you can do is maintain two files. Each time you serialize an object to a file, get the size and persist this size and the object id to another file (call this the "size" file).
When you wish to modify an object, read the size of each object from the "size" file, calculate the bytes you need to skip and the bytes that you need to read. This should do for you. Before adding/deleting use the same logic and update the "size" file.
If the number of objects you are playing with is not large, what you can do is, add ur objects to a list and serizlize this list. Whenever you want to modify an object, read this list, modify the object and serialize the list again.