How to convert an object to byte array in JAVA. The easiest way to convert an object to byte array is to use the Object Serialization ObjectOutputStream. However, there is a problem that object serialization is compatible only with Java. Object serialization cannot be used for socket communication with heterogeneous (c language, .NET, etc.). So the method I found is to use ByteArrayOutputStream...