How to backup ArrayList in Java?

后端 未结 10 1489
刺人心
刺人心 2020-12-09 12:40

I have some data stored as ArrayList. And when I want to backup this data,java bounds two objects forever. Which means when I change values in data ArrayL

10条回答
  •  遥遥无期
    2020-12-09 12:48

    Regarding the cloning problem, once I solved this by serializing the entire collection into a string then serializing it back out into a new object. This forces you to make all your objects serializable and take when two objects really want to reference a single third object, but it can be a pretty good balance of simplicity and usefulness.

    Actually, I haven't tried this but you could probably use a pipe to serialize in and out at the same exact time so that you aren't storing 3 copies in memory (if it's a huge collection)

提交回复
热议问题