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:

  1. store last index used in file load first retrieve , continue sequence
  2. using such ids not considered good, if want uuid (universally unique ids) java provides class such java.util.uuid.

Comments

Popular posts from this blog

'hasOwnProperty' in javascript -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -

How to understand 2 main() functions after using uftrace to profile the C++ program? -