资讯详情

java快速序列化库FST

FST fast-serialization 是重新实现的 Java 快速对象序列化开发包。序列化速度快(2-10倍),体积小,兼容 JDK 本地序列化 JDK 1.7 支持。

Maven:

1

2 de.ruedigermoeller

3 fst

4 1.36

5

示例代码:

01// ! reuse this Object, it caches metadata. Performance degrades massively

02// if you create a new Configuration Object with each serialization !

03static FSTConfiguration conf = FSTConfiguration.createDefaultConfiguration();

04...

05public MyClass myreadMethod(InputStream stream) throws IOException, ClassNotFoundException

06{

07 FSTObjectInput in = conf.getObjectInput(stream);

08 MyClass result = in.readObject(MyClass.class);

09 // DON'T: in.close(); here prevents reuse and will result in an exception

10 stream.close();

11 return result;

12}

13

14public void mywriteMethod( OutputStream stream, MyClass toWrite ) throws IOException

15{

16 FSTObjectOutput out = conf.getObjectOutput(stream);

17 out.writeObject( toWrite, MyClass.class );

18 // DON'T out.close() when using factory method;

19 out.flush();

20 stream.close();

21}

开源中国:http://www.oschina.net/p/fst

标签: 荔波智能电容器fst

锐单商城拥有海量元器件数据手册IC替代型号,打造 电子元器件IC百科大全!

锐单商城 - 一站式电子元器件采购平台