Java objects to solve the operational flow problem once read multiple objects

Problem Description: When the operation object stream should have a lot of small partners meet specific number of objects in the file do not know when reading objects, so when reading I do not know the end of the end judgment flag , or thought so at the end of the return of the object marks the end would be null , resulting in the program will each read error, for such problems to you the following two solutions: (Note: custom object needs to be an object that implements the interface serializable, so that the object serialization function is enabled, otherwise you can not write into file)

1. Place all the objects first with a collection packed , re-write, no matter how many objects there are a collection the next time you read only read once to get another set of traversal without the need to determine the end. (This method is optimal, recommended)

2. After the completion of the write object end rewrite a null , then the next reading is determined whether the object to be read is null , if it is null represents the object has been read. (More difficult, not recommended)

Find useful small partners please Like, comment, or collection of multi-bit Support bloggers brother, Guian ~~

Published 41 original articles · won praise 33 · views 6165

Guess you like

Origin blog.csdn.net/qq_40275740/article/details/104112255