import org.msgpack.core.MessagePack; import org.msgpack.core.MessageBufferPacker; import org.msgpack.core.MessageUnpacker; import java.io.IOException; public class MessagePackExample { public static void main(String[] args) throws IOException { MessagePack messagePack = new MessagePack(); MessageBufferPacker packer = messagePack.newBufferPacker(); packer.packInt(42); packer.packString("Hello, World!"); byte[] packedData = packer.toByteArray(); MessageUnpacker unpacker = messagePack.newUnpacker(packedData); int intValue = unpacker.unpackInt(); String stringValue = unpacker.unpackString(); System.out.println("Int value: " + intValue); System.out.println("String value: " + stringValue); } } <dependency> <groupId>org.msgpack</groupId> <artifactId>msgpack-core</artifactId> <version>0.9.2</version> </dependency>


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