protostuff基于Google Protobuf的java序列化框架,有较好的易用性,相较于其他的序列化工具,对象序列化后的大小更小。
pom文件添加引用:
<dependency>
<groupId>io.protostuff</groupId>
<artifactId>protostuff-runtime</artifactId>
<version>1.6.0</version>
</dependency>
<dependency>
<groupId>io.protostuff</groupId>
<artifactId>protostuff-api</artifactId>
<version>1.6.0</version>
</dependency>
实现代码如下:
ProtostuffUtils.java
public class ProtostuffUtils {
/**
* 默认的缓冲区打下
*/
private static LinkedBuffer buffer = LinkedBuffer.allocate(LinkedBuffer.DEFAULT_BUFFER_SIZE)