Java.io.ObjectInputStream.enableResolveObject() Method

Advertisements


Description

The java.io.ObjectInputStream.enableResolveObject(boolean enable) method enable the stream to allow objects read from the stream to be replaced. When enabled, the resolveObject method is called for every object being deserialized.

If enable is true, and there is a security manager installed, this method first calls the security manager's checkPermission method with the SerializablePermission("enableSubstitution") permission to ensure it's ok to enable the stream to allow objects read from the stream to be replaced.

Declaration

Following is the declaration for java.io.ObjectInputStream.enableResolveObject() method

protected boolean enableResolveObject(boolean enable)

Parameters

  • enable -- true for enabling use of resolveObject for every object being deserialized

Return Value

This method returns the previous setting before this method was invoked

Exception

  • SecurityException -- if a security manager exists and its checkPermission method denies enabling the stream to allow objects read from the stream to be replaced.

Example

The following example shows the usage of java.io.ObjectInputStream.enableResolveObject() method.


Let us compile and run the above program, this will produce the following result:





Advertisements
Advertisements