-1

I want to send an array of bytes with 6 fields (char, boolean[], char, byte[], int, and byte). Each field has a defined size, therefore my array of bytes must have a size limit as big as the sum of the 5 fields.

My question is this: The number serialize uid increases the final size of my bytes array to send? (if the answer is yes I must find another way to convert array of bytes)

Thank you.

4

1 回答 1

0

快速回答,的,默认的 Java 序列化机制确实在它输出的字节中包含序列版本 ID(并在它读回它时期望)。完整的细节在这里http://www.javaworld.com/community/node/2915,它还包括其他东西。

根据http://geekexplains.blogspot.co.uk/2008/05/externalizable-in-java-what-is-it-used.html ,您可以通过实现 Externalizable 来覆盖此行为。

您可能还更喜欢使用 protobuf 或 msgpack 之类的库。

于 2013-04-12T09:49:43.420 回答