Get the first elements of a list while keeping others in memory when reading a serialized file


Suppose I have a list object which has 100 elements which have been serialized into the disk using writeObject(). Now can anyone please tell me what should I do to read only the first ten elements in the list while keeping all the others in the disk. As per my knowledge readObject() reads the entire list into memory. So is there any work around to it. I want to use it in SPIMI implementation of indexing in information retieval.

Thanx in advance :)

I think what you need to do is serialize objects in the list in sequence to the disk. If you do that you can get the first few and stop reading. Avoid serializing the whole list.