08 Java Serialization with memory buffer Theory
Rishi Srivastava Chapter 02 Serialization with memory buffer The first example is using memory as buffer to where the serialized streams of bytes will be written to and then retrieved from using deserialization. Java Object , Serialize to byte array , Memory Memory , Deserialize from byte array , Java Object ByteArrayOutputStream class is used to serialize to byte array. This class implements an output stream in which the data is written into a byte array. The buffer automatically grows as data is written to it. The data can be retrieved using toByteArray() and toString(). ByteArrayInputStream class is used to deserialize from byte array. This class contains an internal buffer that contains bytes that may be read from the stream. An internal counter keeps track of the next byte to be supplied by the rea
|
|