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

Object Serialization and Persistence 对象序列化和持久化 Institute of Computer Software 2022-2-27 Nanjing University
对象序列化和持久化 Object Serialization and Persistence 2022-2-27 Institute of Computer Software Nanjing University 1

&雪扇 摘要 UNIVE 2 口对象序列化 口对象持久化 ▣Language level ▣Databases Hibernate Institute of Computer Software 2022-2-27 Nanjing University
摘要 对象序列化 对象持久化 Language level Databases Hibernate 2022-2-27 Institute of Computer Software Nanjing University 2

&雪扇 摘要 UNIVE 口对象序列化 口对象持久化 ▣Language level ▣Databases Hibernate Institute of Computer Software 2022-2-27 Nanjing University
摘要 对象序列化 对象持久化 Language level Databases Hibernate 2022-2-27 Institute of Computer Software Nanjing University 3

&雪扇 摘要 UNIVE 4 口对象序列化 口对象持久化 ▣Language level ▣Databases Hibernate Institute of Computer Software 2022-2-27 Nanjing University
摘要 对象序列化 对象持久化 Language level Databases Hibernate 2022-2-27 Institute of Computer Software Nanjing University 4

&扇 Object Serialization o Why What 0 How Institute of Computer Software 2022-2-27 Nanjing University
Object Serialization Why What How 2022-2-27 Institute of Computer Software Nanjing University 5

&扇 Java Object Serialization --Why 1002 UNIVE 6 ▣ Serialization is used for lightweight persistence and for communication via sockets or Remote Method Invocation(RMI). Institute of Computer Software 2022-2-27 Nanjing University
Java Object Serialization -- Why Serialization is used for lightweight persistence and for communication via sockets or Remote Method Invocation (RMI). 2022-2-27 Institute of Computer Software Nanjing University 6

Java Object Serialization --Example 102 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); Institute of Computer Software 2022-2-27 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); } } } 2022-2-27 Institute of Computer Software Nanjing University 7

&扇 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.getlnputStream(); ObjectInput s=new ObjectInputStream(o); str =(String)s.readObject(); d =(Date)s.readObject(); s.close(); System.out.println(str);System.out.printIn(d); catch(Exception e){ System.out.printIn(e.getMessage()); System.out.println("Error during serialization"); System.exit(1); } Institute of Computer Software 2022-2-27 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); } } } 2022-2-27 Institute of Computer Software Nanjing University 8

&扇 Java Object Serialization -Example 1902 9 Writing to an object stream /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(); Institute of Computer Software 2022-2-27 Nanjing University
Java Object Serialization -- Example Writing to an object stream 2022-2-27 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();

Java Object Serialization -Example 1902 10 Reading from an object stream /Deserialize a string and date from a file. FilelnputStream in new FilelnputStream("tmp"); ObjectInputStream s new ObjectInputStream(in); String today =(String)s.readObject(); Date date =(Date)s.readObject(); Institute of Computer Software 2022-2-27 Nanjing University
Java Object Serialization -- Example Reading from an object stream 2022-2-27 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();
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 南京大学:《面向对象技术 OOT》课程教学资源(PPT课件讲稿)07 Java并发编程 Concurrent Programming in Java.ppt
- 南京大学:《面向对象技术 OOT》课程教学资源(PPT课件讲稿)06 并发对象 Concurrent Objects.ppt
- 南京大学:《面向对象技术 OOT》课程教学资源(PPT课件讲稿)05 异常处理 Exception Handling.ppt
- 南京大学:《面向对象技术 OOT》课程教学资源(PPT课件讲稿)04 契约式设计 Design by Contract.ppt
- 南京大学:《面向对象技术 OOT》课程教学资源(PPT课件讲稿)03 类和对象 Class and Object.ppt
- 南京大学:《面向对象技术 OOT》课程教学资源(PPT课件讲稿)02 抽象数据类型 Abstract Data Types.ppt
- 南京大学:《面向对象技术 OOT》课程教学资源(PPT课件讲稿)01 Introduction(主讲:余萍).ppt
- 西安石油大学计算机学院:《信息系统分析与设计 Information System Analysis and Design》课程教学资源(PPT课件)第16讲 信息系统应用.ppt
- 西安石油大学计算机学院:《信息系统分析与设计 Information System Analysis and Design》课程教学资源(PPT课件)第15讲 信息系统管理.ppt
- 西安石油大学计算机学院:《信息系统分析与设计 Information System Analysis and Design》课程教学资源(PPT课件)第14讲 实现与测试.ppt
- 西安石油大学计算机学院:《信息系统分析与设计 Information System Analysis and Design》课程教学资源(PPT课件)第13讲 系统设计实践(小区物业管理系统).ppt
- 西安石油大学计算机学院:《信息系统分析与设计 Information System Analysis and Design》课程教学资源(PPT课件)第12讲 详细设计(下)界面设计.ppt
- 西安石油大学计算机学院:《信息系统分析与设计 Information System Analysis and Design》课程教学资源(PPT课件)第11讲 详细设计(中)数据库设计.ppt
- 西安石油大学计算机学院:《信息系统分析与设计 Information System Analysis and Design》课程教学资源(PPT课件)第10讲 详细设计(上).ppt
- 西安石油大学计算机学院:《信息系统分析与设计 Information System Analysis and Design》课程教学资源(PPT课件)第09讲 体系结构设计.ppt
- 西安石油大学计算机学院:《信息系统分析与设计 Information System Analysis and Design》课程教学资源(PPT课件)第08讲 需求建模与总结.ppt
- 西安石油大学计算机学院:《信息系统分析与设计 Information System Analysis and Design》课程教学资源(PPT课件)第07讲 需求分析实践.ppt
- 西安石油大学计算机学院:《信息系统分析与设计 Information System Analysis and Design》课程教学资源(PPT课件)第06讲 需求分析.ppt
- 西安石油大学计算机学院:《信息系统分析与设计 Information System Analysis and Design》课程教学资源(PPT课件)第05讲 领域分析.ppt
- 西安石油大学计算机学院:《信息系统分析与设计 Information System Analysis and Design》课程教学资源(PPT课件)第04讲 信息系统规划.ppt
- 南京大学:《面向对象技术 OOT》课程教学资源(PPT课件讲稿)09 面向对象的分析与设计简介 OOA & OOD:An introduction.ppt
- 南京大学:《面向对象技术 OOT》课程教学资源(PPT课件讲稿)10 敏捷软件开发 Agile Software Development.ppt
- 南京大学:《面向对象技术 OOT》课程教学资源(PPT课件讲稿)11 设计模式 Design Patterns(1).ppt
- 南京大学:《面向对象技术 OOT》课程教学资源(PPT课件讲稿)12 设计模式 Design Patterns(2).ppt
- 南京大学:《面向对象技术 OOT》课程教学资源(PPT课件讲稿)13 设计模式 Design Patterns(3).ppt
- 南京大学:《面向对象技术 OOT》课程教学资源(PPT课件讲稿)14 模式和框架 Pattern and Framework.ppt
- 南京大学:《面向对象技术 OOT》课程教学资源(PPT课件讲稿)15 面向方面的编程 Aspect Oriented Programming(AOP).ppt
- 南京大学:《面向对象技术 OOT》课程教学资源(PPT课件讲稿)16 构件化软件 Component Software.ppt
- 南京大学:《面向对象技术 OOT》课程教学资源(PPT课件讲稿)17 分布对象 Distributed Objects(1).ppt
- 南京大学:《面向对象技术 OOT》课程教学资源(PPT课件讲稿)18 分布对象 Distributed Objects(2).ppt
- 南京大学:《面向对象技术 OOT》课程教学资源(PPT课件讲稿)19 复习和总结 Object-Oriented Technology:Review and Conclusion Remarks.ppt
- 南京大学:《面向对象技术 OOT》课程教学资源(PPT课件讲稿)实习项目概述.ppt
- 南京大学:《面向对象技术 OOT》课程教学资源(实习指南)医院预约挂号系统.docx
- 南京大学:《面向对象技术 OOT》课程教学资源(PPT课件讲稿)OOT实习指南.pptx
- 南京大学:《面向对象技术 OOT》课程教学资源(教材电子版)33 O-O programming and Ada.pdf
- 南京大学:《面向对象技术 OOT》课程教学资源(教材电子版)06 Abstract data types.pdf
- 南京大学:《面向对象技术 OOT》课程教学资源(教材电子版)27 Object-oriented analysis.pdf
- 南京大学:《面向对象技术 OOT》课程教学资源(教材电子版)E Bibliography.pdf
- 南京大学:《面向对象技术 OOT》课程教学资源(教材电子版)07 The static structure:classes.pdf
- 南京大学:《面向对象技术 OOT》课程教学资源(教材电子版)30 Concurrency, distribution, client-server and the Internet.pdf