Let\'s say I have a serializable class AppMessage.
AppMessage
I would like to transmit it as byte[] over sockets to another machine where it is rebuil
byte[]
If you are using spring, there's a util class available in spring-core. You can simply do
import org.springframework.util.SerializationUtils; byte[] bytes = SerializationUtils.serialize(anyObject); Object object = SerializationUtils.deserialize(bytes);