FSTfast-serializatio是重新实现的Java快速对象序列化的开发包。序列化速度更快(2-10倍)、体积更小,而且兼容JDK原生的序列化。要求JDK1.7支持。
Mave:
<depedecy> <groupId>de.ruedigermoeller</groupId> <artifactId>fst</artifactId> <versio>1.58</versio></depedecy>示例代码:
// ! reuse this Object, it caches metadata. Performace degrades massively// if you create a ew Cofiguratio Object with each serializatio !static FSTCofiguratio cof = FSTCofiguratio.createDefaultCofiguratio();...public MyClass myreadMethod(IputStream stream) throws IOExceptio, ClassNotFoudExceptio{ FSTObjectIput i = cof.getObjectIput(stream); MyClass result = i.readObject(MyClass.class); // DON'T: i.close(); here prevets reuse ad will result i a exceptio stream.close(); retur result;}public void mywriteMethod( OutputStream stream, MyClass toWrite ) throws IOExceptio { FSTObjectOutput out = cof.getObjectOutput(stream); out.writeObject( toWrite, MyClass.class ); // DON'T out.close() whe usig factory method; out.flush(); stream.close();}
评论