What is Externalizable?

Asked 2 years ago, Updated 2 years ago, 48 views

I don't know the big difference from Serializable, but what are you using this for?

java externalizable

2022-09-22 22:20

1 Answers

The Externalizable interface is an extension of the Serializable interface and has a trim that can directly control detailed fields. You can also use the transient keyword to exclude certain fields, but you can use the Externalizable interface when more detailed work is needed.

Externalizable interface The Externalizable interface helps you freely manipulate the contents inside when reading and writing objects through an object stream and output the desired contents. To this end, this interface extends the serializable interface and adds two methods. One is the writeExternal() method for output and the other is the readExternal() method for input.

Behavior in object stream serialization (1) Output (serialization)

When a method of outputting an object through an object stream is called, the first thing to check is whether the class of the object implements an externalizable interface. If implemented, the transmission data is serialized through the writeExternal() method.

If you have not implemented the Externalizable interface, make sure that you have implemented the Serializable interface. If a serializable interface is implemented, the entire object is serialized in the object stream as it is.

If the Externalizable and Serializable interfaces are not implemented, an exception occurs.

(Station of series)

(2).

(3) writeExternal(), readExternal()


2022-09-22 22:20

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.