java - Initiating a second Random object using the same seed -


using seed can random object spit same sequence of numbers on , on again. if want shut down app, relaunch , continue spitting numbers left off? initiating new random same seed starts sequence again.

so.. apart maintaining list of calls made random , re-calling them same position, there better way?

edit: zim-zam has pointed out using java serialization reinitiate object don't want add single java object save files otherwise entirely xml.

you can serialize random object objectoutputstream save state; when start program again, deserialize objectinputstream , random start left off.

alternatively, copy-paste java random source code own myrandom generator; give access internal workings of generator can save , restore state.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -