Serialized techniques for objects in Java

xiaoxiao2021-03-06  40

Serialized techniques for objects in Java

Time: 2003-10-2 14:15:46 Source: net Author End of the World: Yang Shaobo Read 672 times

1, meaning: Save the status of an object (amount) and then get again at appropriate. 2. Programming requirements: Only class objects that implement the serializable interface can be serialized. The Serializable interface does not define any members, which only uses a class that can be serialized. 3. Characteristics of serialization: (1) If a class can be serialized, its subclass can also be serialized. (2) Notice of member data for Static and Transient types cannot be serialized. Because Static represents the state of the class, Transient represents the temporary data of the object. (3) the relevant classes and interfaces: provides the following objects involved in a sequence of java.io package classes and interfaces ObjectOutput interfaces, classes ObjectOutputStream, ObjectInput interfaces, ObjectInputStream class 4, ObjectOutput ObjectOutputStream interfaces and classes (. 1) ObjectOutput Interface: It inherits the DataOutput interface and supports serialization of the object, and the WriteObject () method is implemented to store an object. (2) ObjectOutputStream Class: It inherits the OutputStream class and implements the ObjectOutput interface. Use this class to implement the object storage (call the WriteObject () method in the ObjectOutput interface). Note: (1) You can also use the object of the ObjectOutputStream class to write to other basic types of data values. (2) IoException is throwing out when an error occurs. 5. ObjectInput interface and ObjectInputStream class (1) ObjectInput interface: it inherits the DataInput interface and supports serialization of the object, and the in-readObject () method implements an object. (2) ObjectInputStream Class: It inherits the InputStream class and implements the ObjectInput interface. Use this class to implement the object store (call the readObject () method in the ObjectInput interface). Note: (1) The data value of other basic types can also be read using an object of the ObjectInputStream class. (2) IoException is throwing out when an error occurs. 6, the sequence of objects: Using the sequence of objects to save the current operating state of the application, the next time the next time is started, it will automatically return to the status of the last execution.

转载请注明原文地址:https://www.9cbs.com/read-76105.html

New Post(0)