Freigeben über


ObjectInputStream.ReadObject Method

Definition

Read an object from the ObjectInputStream.

[Android.Runtime.Register("readObject", "()Ljava/lang/Object;", "")]
public Java.Lang.Object? ReadObject ();
[<Android.Runtime.Register("readObject", "()Ljava/lang/Object;", "")>]
abstract member ReadObject : unit -> Java.Lang.Object
override this.ReadObject : unit -> Java.Lang.Object

Returns

Implements

Attributes

Exceptions

if the class of one of the objects in the object graph cannot be found.

if an error occurs while reading from the source stream.

if primitive data types were found instead of an object.

Remarks

Read an object from the ObjectInputStream. The class of the object, the signature of the class, and the values of the non-transient and non-static fields of the class and all of its supertypes are read. Default deserializing for a class can be overridden using the writeObject and readObject methods. Objects referenced by this object are read transitively so that a complete equivalent graph of objects is reconstructed by readObject.

The root object is completely restored when all of its fields and the objects it references are completely restored. At this point the object validation callbacks are executed in order based on their registered priorities. The callbacks are registered by objects (in the readObject special methods) as they are individually restored.

Exceptions are thrown for problems with the InputStream and for classes that should not be deserialized. All exceptions are fatal to the InputStream and leave it in an indeterminate state; it is up to the caller to ignore or recover the stream state.

Java documentation for java.io.ObjectInputStream.readObject().

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

See also