Read object from file in java -
i have class has method generate id incrementally created objects , add vector ,then save .dat file read file , add objects vector but, when open program again create objects, starts initial id, doesn't continue last id. solution this?
you using counter-like id generator , starting id being initialized during startup. 2 ways:
- store last index used in file load first retrieve , continue sequence
- using such ids not considered good, if want uuid (universally unique ids) java provides class such
java.util.uuid
.
Comments
Post a Comment