FST 2.05 发布,Java 快速序列化库
第29期OSC源创会#南京#开始报名,AngularJS、Netty 等
FST 2.05 发布,此版本现已提供下载,主要是 bug 修复(JDK 兼容问题)。
FST fast-serialization 是重新实现的 Java 快速对象序列化的开发包。序列化速度更快(2-10倍)、体积更小,而且兼容 JDK 原生的序列化。要求 JDK 1.7 支持。
Maven:
<dependency> <groupId>de.ruedigermoeller</groupId> <artifactId>fst</artifactId> <version>1.58</version></dependency>
示例代码:
// ! reuse this Object, it caches metadata. Performance degrades massively// if you create a new Configuration Object with each serialization !static FSTConfiguration conf = FSTConfiguration.createDefaultConfiguration();...public MyClass myreadMethod(InputStream stream) throws IOException, ClassNotFoundException{ FSTObjectInput in = conf.getObjectInput(stream); MyClass result = in.readObject(MyClass.class); // DON'T: in.close(); here prevents reuse and will result in an exception stream.close(); return result;}public void mywriteMethod( OutputStream stream, MyClass toWrite ) throws IOException { FSTObjectOutput out = conf.getObjectOutput(stream); out.writeObject( toWrite, MyClass.class ); // DON'T out.close() when using factory method; out.flush(); stream.close();}