Java Core API-12 (object serialization and deserialization)

Source: Internet
Author: User
Tags object serialization

1. Serialization of objects

The process of converting an object to a byte form is object serialization. Serialization also has a name of serialization, the serialized object is then deserialized after the resulting object, and the previous object is no longer the same object.

1) object serialization must implement the Serializable interface, but there is no abstract method for the interface, and no overriding method is required just to label the class serializable.

2) at the same time, it is advisable to add the version number (the number is casually written): Serialversionuid. The version number that matches whether the current class is in the same feature as the object it is deserializing (the property list is consistent, and so on). When deserializing, ObjectInputStream determines whether to deserialize based on the version of the deserialized object that matches the current version. No version number is allowed, but there may be a risk of deserialization failure.

3) Most Java beans provided by the JDK implement the interface

4) Transient keyword: ignores attributes that it modifies when serializing.

5) class used for serialization of objects: ObjectOutputStream

WriteObject (Object obj): ① serializes the given object. ② then writes.

6) The class used by the deserialization of the object: ObjectInputStream

Object ReadObject (): Restores the read sequence of bytes to an object

Case Study:

650) this.width=650; "title=" Clipboard-28.png "src=" http://s3.51cto.com/wyfs02/M02/71/1C/ Wkiom1xfz9tyhdsfaanxrtvuejw190.jpg "alt=" Wkiom1xfz9tyhdsfaanxrtvuejw190.jpg "/>

650) this.width=650; "title=" Clipboard-28-2.png "src=" http://s3.51cto.com/wyfs02/M01/71/19/ Wkiol1xf0els9pekaajxu4oaqgg665.jpg "alt=" Wkiol1xf0els9pekaajxu4oaqgg665.jpg "/>

This article is from "Forever Young" blog, please be sure to keep this source http://kingkongzhao.blog.51cto.com/6319491/1682940

Java Core API--12 (object serialization and deserialization)

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.