开发者

Saving object state on Java without using external memory

Good day. I know that in order to save object state 开发者_开发问答in Java I should use serialization. But in every single topic about serialization states that I must save my object somewhere (disk, network). My problem is that I'm not allowed to do so. I need a way to save and recover object state without writing it on "external" memory. Maybe to save it on heap or stack... Please don't offer to clone it, I'm not allowed to do so as well. Thanks.


You can serialize to a ByteArrayOuputStream. Just pass one to the ObjectOutputStream constructor. When you're done, you can call toByteArray

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜