import org.msgpack.core.MessageBufferPacker; import org.msgpack.core.MessagePack; import org.msgpack.core.MessageUnpacker; public class MessagePackExample { public static void main(String[] args) throws Exception { MessageBufferPacker packer = MessagePack.newDefaultBufferPacker(); packer.packString("Hello"); packer.packInt(42); byte[] serializedData = packer.toByteArray(); MessageUnpacker unpacker = MessagePack.newDefaultUnpacker(serializedData); String strValue = unpacker.unpackString(); int intValue = unpacker.unpackInt(); System.out.println("Serialized Data: " + serializedData); System.out.println("Deserialized String: " + strValue); System.out.println("Deserialized Int: " + intValue); } }


上一篇:
下一篇:
切换中文