If you like Smalltalk, Programming, eXtreme Programming, Agile Methods, Software Development... here you can find the answer to all your questions, the answer is... 42.
rr := SmartRefStream fileNamed: 'test.obj'. rr nextPut: yourObject. rr close.
rr := SmartRefStream fileNamed: 'test.obj'. yourObject := rr next. rr close.