南京大学:《面向对象技术 OOT》课程教学资源(PPT课件讲稿)对象序列化和持久化 Object Serialization and Persistence

Obiect Serialization and Persistence 对象序列化和持久化 Institute of Computer Software 2021/1/28 Nanjing University
对象序列化和持久化 Object Serialization and Persistence 2021/1/28 Institute of Computer Software Nanjing University 1

最病 过摘要 口对象序列化 口对象持久化 a language level a Databases Hibernate Institute of Computer Software 2021/1/28 Nanjing University
摘要 对象序列化 对象持久化 Language level Databases Hibernate 2021/1/28 Institute of Computer Software Nanjing University 4

最病 ○ bject Serialization 5 口Why a What 口HoW Institute of Computer Software 2021/1/28 Nanjing University
Object Serialization Why What How 2021/1/28 Institute of Computer Software Nanjing University 5

最病 A Java Object Serialization --Why 6 a Serialization is used for light weight persistence and for communication via sockets or remote method Invocation (RMI) Institute of Computer Software 2021/1/28 Nanjing University
Java Object Serialization -- Why Serialization is used for lightweight persistence and for communication via sockets or Remote Method Invocation (RMI). 2021/1/28 Institute of Computer Software Nanjing University 6

最病 A Java Object Serialization --Example 7 public class Client public static void main( String args[) try(//Create a socket Socket soc new Socket(Inet Address getLocalHost(), 8020) ○ utput Strean。= soc. get Output Stream(); Object Output s new Object Output Stream(o); s write Object("Todays date"); swrite Object(new Date())i sclose();] catch(Exception e)t System. out. printIn(e get Message()) System. out. printIn (" Error during serialization") System. exit(1);] Institute of Computer Software 2021/1/28 Nanjing University
Java Object Serialization -- Example public class Client { public static void main(String args[]) { try { // Create a socket Socket soc = new Socket(InetAddress.getLocalHost(), 8020); OutputStream o = soc.getOutputStream(); ObjectOutput s = new ObjectOutputStream(o); s.writeObject("Today's date"); s.writeObject(new Date()); s.flush(); s.close(); } catch (Exception e) { System.out.println(e.getMessage()); System.out.println("Error during serialization"); System.exit(1); } } } 2021/1/28 Institute of Computer Software Nanjing University 7

最病 A Java Object Serialization --Example 8 public class Server public static void main(String args[)( Server Socket ser= null: Socket soc String str null; Date d null; ser= new Server Socket(8020); sOc= ser. accept( Input Stream o F soc. getlnput Stream(; Objectlnput s new ObjectInput Stream(o); tr=(String)s readobject(; d=(Date)s readObject( sclose( System. out. printIn(str ); System. out. printin( d); 3 catch(Exception e) System. out. printin(e getMessage () System. out printIn("Error during serialization") System. exit(1) Institute of Computer Software 2021/1/28 Nanjing University
Java Object Serialization -- Example public class Server { public static void main(String args[]) { ServerSocket ser = null; Socket soc = null; String str = null; Date d = null; try { ser = new ServerSocket(8020); soc = ser.accept(); InputStream o = soc.getInputStream(); ObjectInput s = new ObjectInputStream(o); str = (String) s.readObject(); d = (Date) s.readObject(); s.close(); System.out.println(str); System.out.println(d); } catch (Exception e) { System.out.println(e.getMessage()); System.out.println("Error during serialization"); System.exit(1); } } } 2021/1/28 Institute of Computer Software Nanjing University 8

最病 A Java Object Serialization --Example 9 a Writing to an object stream l/ Serialize today's date to a file FileOutputStream f new FileOutput Stream(tmp") Objectoutput s= new ObjectoutputStream(t) s writeobject( Today) s writeobject(new DateD) S flush Institute of Computer Software 2021/1/28 Nanjing University
Java Object Serialization -- Example Writing to an object stream 2021/1/28 Institute of Computer Software Nanjing University 9 // Serialize today's date to a file. FileOutputStream f = new FileOutputStream("tmp"); ObjectOutput s = new ObjectOutputStream(f); s.writeObject("Today"); s.writeObject(new Date()); s.flush();

最病 A Java Object Serialization --Example n Reading from an object stream // Deserialize a string and date from a file FileInputStream in= new FileInputStream (" tmp") ObjectInputStream s= new objectInputstream(in) String today =(String)s. readobjecto Date date =(Date)s readobject( Institute of Computer Software 2021/1/28 Nanjing University
Java Object Serialization -- Example Reading from an object stream 2021/1/28 Institute of Computer Software Nanjing University 10 // Deserialize a string and date from a file. FileInputStream in = new FileInputStream("tmp"); ObjectInputStream s = new ObjectInputStream(in); String today = (String)s.readObject(); Date date = (Date)s.readObject();

最病 A Java Object Serialization --What a Object Serialization extends the core Java Input Output classes with support for objects a Object Serialization supports the encoding of objects, and the objects reachable from them, into a stream of bytes; and it supports the complementary reconstruction of the object graph from the stream Institute of Computer Software 2021/1/28 Nanjing University
Java Object Serialization -- What Object Serialization extends the core Java Input/Output classes with support for objects. Object Serialization supports the encoding of objects, and the objects reachable from them, into a stream of bytes; and it supports the complementary reconstruction of the object graph from the stream. 2021/1/28 Institute of Computer Software Nanjing University 11

最病 A Java Object Serialization --Goal o Have a simple yet extensible mechanism a maintain the Java object type and safety properties in the serialized form n Be extensible to support marshaling and unmarshaling as needed for remote objects a Be extensible to support simple persistence of java objects n Require per class implementation only for customization. o Allow the object to define its external format Institute of Computer Software 2021/1/28 Nanjing University
Java Object Serialization -- Goal Have a simple yet extensible mechanism. Maintain the Java object type and safety properties in the serialized form. Be extensible to support marshaling and unmarshaling as needed for remote objects. Be extensible to support simple persistence of Java objects. Require per class implementation only for customization. Allow the object to define its external format. 2021/1/28 Institute of Computer Software Nanjing University 12
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 电子工业出版社:《计算机网络》课程教学资源(第五版,PPT课件讲稿)第十章 下一代因特网.ppt
- 《网络编程实用教程(第三版)Network Application Programming》课程教学资源(PPT课件讲稿)第1章 概述.ppt
- 武昌理工学院(武汉科技大学中南分校):Windows 2000/XP网络组建与系统管理(PPT课件讲稿,主讲:李燕).ppt
- 《计算机导论》课程教学资源(PPT课件讲稿)第3章 计算机发展史和计算思维.pptx
- 电子工业出版社:《计算机网络》课程教学资源(第五版,PPT课件讲稿)第六章 应用层.ppt
- 中国科学技术大学:《计算机视觉》课程教学资源(PPT课件讲稿)第九章 单幅图像深度重建 Depthmap Reconstruction Based on Monocular cues.ppt
- 图像视频编码与表达的理论与方法(PPT讲稿)图像压缩标准JPEG.ppt
- 九州大学(日本国立综合大学):烟花算法爆炸因子分析及改良(艺术工学府:余俊).pptx
- 广西外国语学院:《计算机网络》课程教学资源(PPT课件讲稿)第7章 传输层协议——TCP与UDP.ppt
- 《电子商务》课程教学资源(PPT课件讲稿)第十章 网络营销.pptx
- 湖南生物机电职业技术学院:《电子商务概论》课程教学资源(PPT课件)第五章 网络信息搜索.ppt
- 《VB程序设计》课程教学资源(PPT课件讲稿)第八章 过程.pps
- 武昌首义学院:Word的基本操作与技巧(PPT讲稿,主讲:张旋子).pptx
- 南京大学:《面向对象技术 OOT》课程教学资源(PPT课件讲稿)面向方面的编程 Aspect Oriented Programming.ppt
- 山东大学:《微机原理及单片机接口技术》课程教学资源(PPT课件讲稿)第三章 IAP15W4K58S4单片机的硬件结构.ppt
- 山东大学计算机学院:《人机交互技术》课程教学资源(PPT课件讲稿)第7章 Web界面设计.ppt
- 上海交通大学:TLS/SSL Security(PPT课件讲稿).pptx
- 香港科技大学:Clustering(PPT讲稿).ppt
- 电子科技大学:《计算机操作系统》课程教学资源(PPT课件讲稿)第三章 处理机的调度和死锁.ppt
- 《图像处理与计算机视觉 Image Processing and Computer Vision》课程教学资源(PPT课件讲稿)Chapter 11 Bundle adjustment Structure reconstruction SFM from N-frames.pptx
- B-树、散列技术、散列表的概念、散列函数的构造方法、处理冲突的方法、散列表上的运算.ppt
- 四川大学:《软件测试与维护基础教程》课程教学资源(PPT课件讲稿)软件测试工具 Software Testing Tool.ppt
- 《数字图像处理学》课程教学资源(PPT课件讲稿)第2章 图像、图像系统与视觉系统.pptx
- 同济大学:聚类分析(PPT课件讲稿)Cluster Analysis.pptx
- 西安电子科技大学:《微机原理与接口技术》课程教学资源(PPT课件讲稿)第九章 定时/计数器8253.pptx
- 汤姆森 Thomson:利用Web of Knowledge对课题进行检索、分析、跟踪、管理.ppt
- 计算机系教学资源(PPT课件讲稿)信息安全与保密技术.ppt
- 北京师范大学:拓扑序及其量子相变(PPT课件讲稿)Topological Order and its Quantum Phase Transition.ppt
- 数据集成 Data Integration(PPT讲稿)成就与展望 Achievements and Perspectives.ppt
- 山东大学:语音识别技术(PPT课件讲稿)自动语音识别 Automatic Speech Recognition.pptx
- 电子科技大学:《计算机操作系统》课程教学资源(PPT课件讲稿)第五章 设备管理.ppt
- 《计算机文化基础》课程教学资源(PPT课件讲稿)第二章 Windows XP操作系统.ppt
- 香港科技大学:《软件开发》教学资源(PPT课件讲稿)Functions.ppt
- 南京大学:复杂系统学习(PPT课件讲稿)佩特里网 Petri Nets.pptx
- 《3ds Max》教学资源(PPT课件)第4章 基本三维模型的创建.ppt
- 上海交通大学:《程序设计》课程教学资源(PPT课件讲稿)第6章 过程封装——函数.ppt
- 四川大学:《操作系统 Operating System》课程教学资源(PPT课件讲稿)Chapter 5 互斥与同步(Mutual Exclusion and Synchronization)5.4 Monitors 5.5 Message Passing 5.6 Readers/Writers Problem.ppt
- 清华大学:An Efficient Trie-based Method for Approximate Entity Extraction with Edit-Distance Constraints.pptx
- 东南大学:《数据结构》课程教学资源(PPT课件讲稿)第三章 栈与队列.ppt
- 《计算机网络与因特网 Computer Networks and Internets》课程教学资源(PPT课件讲稿)Part II 物理层(信号、媒介、数据传输).ppt