What is serialization? Under what circumstances will the class be serialized?

Source: Internet
Author: User
Tags object serialization

Serialization is a mechanism for handling object flow, so-called object flow is the flow of the object's contents. The object can be streamed to read and write operations, but also the flow of the transferred object between the network. Serialization is a problem that is raised when reading and writing to an object stream.

Serialization implementation: Implement the Serializable interface for the class that needs to be serialized, there is no method to implement it, implements serializable just to annotate that the object is serializable, and then use an output stream ( such as: FileOutputStream) to construct a ObjectOutputStream object, followed by the WriteObject (object obj) of the ObjectOutputStream object method to write out (that is, save its state) the object with the parameter obj, and the input stream to restore.

Serialization: Serialization is the process of converting an object into a format that is easy to transfer, for example, you can serialize an object and then use HTTP to transfer the object between the client and the server over the Internet. At the other end, deserialization reconstructs the object from the stream.

is a mechanism for object persistence.
Specifically, the object should be serialized, the general program at run time, the object is generated, these objects disappear as the program stops running, but if we want to put some objects (because it is the object, so there are different characteristics) to save, after the program terminates, these objects still exist, You can read the values of these objects while the program is running again, or take advantage of these saved objects in other programs. In this case, the serialization of the object is used.

The most important use of object serialization is to guarantee the integrity and transitivity of objects when passing, and saving objects (object). For example, when transmitting over a network, or storing an object as a file, the serialization interface is implemented.

What is serialization? Under what circumstances will the class be serialized?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.