gpt4 book ai didi

java - java中的序列化和外部化

转载 作者:行者123 更新时间:2023-12-01 07:43:01 26 4
gpt4 key购买 nike

Possible Duplicate:
What is the difference between Serializable and Externalizable in Java?

java中序列化和外部化有什么区别?

最佳答案

基本上,Serializable 之间的区别和 Externalizable实现 Serialized 的类会自动处理对象的序列化,而实现 Externalizable 的类则负责序列化自身,无需默认序列化的帮助程序。

Externalizable 的 API 规范中提供了更多信息。界面,以及 Serializable界面。来自 Externalized 接口(interface)文档:

Only the identity of the class of an Externalizable instance is written in the serialization stream and it is the responsibility of the class to save and restore the contents of its instances. The writeExternal and readExternal methods of the Externalizable interface are implemented by a class to give the class complete control over the format and contents of the stream for an object and its supertypes.

Discover the secrets of the Java Serialization API本文的“创建您自己的协议(protocol):Externalized 接口(interface)”部分对 Externalized 接口(interface)进行了讨论。

关于java - java中的序列化和外部化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1025513/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com