对象序列化和持久化

对象序列化和持久化

ID:27680364

大小:1.69 MB

页数:95页

时间:2018-12-02

对象序列化和持久化_第1页
对象序列化和持久化_第2页
对象序列化和持久化_第3页
对象序列化和持久化_第4页
对象序列化和持久化_第5页
资源描述:

《对象序列化和持久化》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、对象序列化和持久化ObjectSerializationandPersistence2021/9/8InstituteofComputerSoftwareNanjingUniversity1摘要对象序列化对象持久化LanguagelevelDatabasesHibernate2021/9/8InstituteofComputerSoftwareNanjingUniversity2摘要对象序列化对象持久化LanguagelevelDatabasesHibernate2021/9/8InstituteofComputerSoftwareNa

2、njingUniversity3摘要对象序列化对象持久化LanguagelevelDatabasesHibernate2021/9/8InstituteofComputerSoftwareNanjingUniversity4ObjectSerializationWhyWhatHow2021/9/8InstituteofComputerSoftwareNanjingUniversity5JavaObjectSerialization--WhySerializationisusedforlightweightpersistenceandfo

3、rcommunicationviasocketsorRemoteMethodInvocation(RMI).2021/9/8InstituteofComputerSoftwareNanjingUniversity6JavaObjectSerialization--ExamplepublicclassClient{publicstaticvoidmain(Stringargs[]){try{//CreateasocketSocketsoc=newSocket(InetAddress.getLocalHost(),8020);OutputS

4、treamo=soc.getOutputStream();ObjectOutputs=newObjectOutputStream(o);s.writeObject("Today'sdate");s.writeObject(newDate());s.flush();s.close();}catch(Exceptione){System.out.println(e.getMessage());System.out.println("Errorduringserialization");System.exit(1);}}}2021/9/8In

5、stituteofComputerSoftwareNanjingUniversity7JavaObjectSerialization--ExamplepublicclassServer{publicstaticvoidmain(Stringargs[]){ServerSocketser=null;Socketsoc=null;Stringstr=null;Dated=null;try{ser=newServerSocket(8020);soc=ser.accept();InputStreamo=soc.getInputStream();

6、ObjectInputs=newObjectInputStream(o);str=(String)s.readObject();d=(Date)s.readObject();s.close();System.out.println(str);System.out.println(d);}catch(Exceptione){System.out.println(e.getMessage());System.out.println("Errorduringserialization");System.exit(1);}}}2021/9/8I

7、nstituteofComputerSoftwareNanjingUniversity8JavaObjectSerialization--ExampleWritingtoanobjectstream2021/9/8InstituteofComputerSoftwareNanjingUniversity9//Serializetoday'sdatetoafile.FileOutputStreamf=newFileOutputStream("tmp");ObjectOutputs=newObjectOutputStream(f);s.wri

8、teObject("Today");s.writeObject(newDate());s.flush();JavaObjectSerialization--ExampleReadingfromanobjec

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。