Java object serialization and deserialization Methods

Source: Internet
Author: User
Tags object serialization

When two processes perform remote communication, they can send different types of data to each other. Regardless of the type of data, it is transmitted on the network in the form of binary sequence. The sender needs to convert the Java object into a byte sequence before it can be transmitted over the network. The receiver needs to restore the byte sequence to a Java object.

The process of converting a Java object to a byte sequence is called object serialization.

The process of restoring a byte sequence to a Java object is called object deserialization.

Object serialization has two main purposes:

1) the object's byte sequence is permanently stored on the hard disk, usually stored in a file;

2) transmits the object's byte sequence over the network.

I. serialization API in JDK class library

Java. io. ObjectOutputStream represents the Object output stream. Its writeObject (Object obj) method can serialize the obj Object specified by the parameter and write the obtained byte sequence to a target output stream.

Java. io. ObjectInputStream indicates the input stream of the object, its readObje

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.