0

Lets say I have 5 objects of some class A (obj1, obj2, obj3, obj4, obj5).

Now I am saving them in a file named "ABC" in order (obj1, obj2, obj3, obj4, obj5).

After saving them lets say the state of object obj3 changes and now i want to update the state of obj3 in file.

Method That i know how to do that is : Create Another file "XYZ" and first save obj1 and obj2 from the "ABC" into "XYZ", then save obj3(with changed state) and then save obj4 and from the "ABC" into "XYZ".

I want to know

1).Is their any better way by which i can do this?

2).Can i travel through the objects in file and can perform Deletion and Updation of a Object by some method?

Jay Patel
  • 505
  • 6
  • 10

1 Answers1

0

You can directly overwrrite all the objects in file "ABC". No need to create new file "XYZ" just to update the state. Overwrrite again with take same time as copying form one file to another.

Else in "ABC" store objects with key associated with each object. When state of any object changed just update object for the correcponding key.