Skip to content
Advertisement

Java Serializable Object to Byte Array

Let’s say I have a serializable class AppMessage.

I would like to transmit it as byte[] over sockets to another machine where it is rebuilt from the bytes received.

How could I achieve this?

Advertisement

Answer

Prepare the byte array to send:

JavaScript

Create an object from a byte array:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement