flâneur — a map of the web's best reading

Java Serialization: readObject() vs. readResolve() | Baeldung

baeldung.com · 1,836 words · saved by 1 readers

In this tutorial, we’ll look at how to use readObject() and readResolve() methods in the Java deserialization API. Furthermore, we’ll examine the difference between these two methods. Java Serialization covers how serialization and deserialization work in greater depth. In this article, we’ll focus on the readResolve() and readObject() methods, which frequently raise questions when employing deserialization. A Java object is converted into a stream of bytes during serialization to be saved in a file or transferred over the internet. The serialized stream of bytes is transformed back into the original object during deserialization using ObjectInputStream‘s readObject() method, which internally calls defaultReadObject() for default deserialization. If the readObject() method is present in our class, ObjectInputStream‘s readObject() method will use our class’s readObject() method for reading the object from the stream. For instance, in some cases, we can implement readObject() in our clas

eBook – Guide Spring Cloud – NPI EA (cat=Spring Cloud) Let's get started with a Microservice Architecture with Spring Cloud: >> Join Pro and download the eBook eBook – Mockito – NPI EA (tag = Mockito) Mocking is an essential part of unit testing, and the Mockito library makes it easy to write clean and intuitive unit tests for your Java code. Get started with mocking and improve your application tests using our Mockito guide : Download the eBook eBook – Java Concurrency – NPI EA (cat=Java Concurrency) Handling concurrency in an application can be a tricky pr

Explore this link on the map →

related reading