Serialization and Deserialization Bullet points from Head First Java, Ch. 14 6-Dec-18 serialization.ppt.

Slides:



Advertisements
Similar presentations
A Guide to Advanced Java Faculty:Nguyen Ngoc Tu. 2 Operating System Application #1 Application #2 Java Virtual Machine #1 Local Memory Shared Memory Threads.
Advertisements

Streams Dwight Deugo Nesa Matic Portions of the notes for this lecture include excerpts from.
Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 Serialization Flatten your object for automated storage or network.
Slide 10.1 Advanced Programming 2004, based on LY Stefanus’s Slides Object Serialization Object serialization: the process of converting an object into.
CSC 243 – Java Programming, Spring 2013 March 26, 2013 Week 8, java.lang.Clonable & java.io.Serializable Interfaces.
Chapter - 12 File and Streams (continued) This chapter includes -  DataOutputStream  DataInputStream  Object Serialization  Serializing Objects 
1 Chapter 6: Extending classes and Inheritance. 2 Basics of Inheritance One of the basic objectives of Inheritance is code reuse If you want to extend.
JAVA: An Introduction to Problem Solving & Programming, 7 th Ed. By Walter Savitch ISBN © 2015 Pearson Education, Inc., Upper Saddle River,
COP INTERMEDIATE JAVA Exception Handling Serialization.
Lecture 31 File I/O -Part 2 COMP1681 / SE15 Introduction to Programming.
ITEC200 – Week03 Inheritance and Class Hierarchies.
1 Chapter 8 Three Interfaces: Cloneable, Serializable, and Runnable.
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 12  File Input and Output Stream Classes Text Input and Output.
File-based Persistence: Serializability COMP53 Dec 7, 2007.
1 Chapter 7 Inheritance, Polymorphism, and Scope.
Unit 201 File IO Binary Files Reading and Writing Binary Files Writing Objects to files Reading Objects from files.
Slides prepared by Rose Williams, Binghamton University Chapter 10 File I/O.
Advanced Java Class Serialization. Serialization – what and why? What? –Translating the contents of an Object to a series of bytes that represent it,
1 Java object model Part 3: Serialization & Reflection.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L08 (Chapter 18) Binary I/O.
13.1 Understanding Files The File class Objects can read and write to the file system Use the File class to hold information about files and directories.
Files and Streams (part 2) 1 -Based on slides from Deitel & Associates, Inc. - Revised by T. A. Yang.
More on Inheritance Dr. Andrew Wallace PhD BEng(hons) EurIng
Object Input/Output. Object I/O  To write objects to a file, we use ObjectOutputStream  To read objects from a file we use ObjectInputStream  Lets.
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2008 Pearson Education, Inc., Upper.
Java I/O Writing and Reading Objects to File Serialization.
Java How to Program, 8/e © by Pearson Education, Inc. All Rights Reserved.
JAVA I/O © EnhanceEdu, IIIT Hyderabad. Contents 3/29/2010EnhanceEdu, IIIT - H 2  Command Line I/O  File Class  Streams  Byte Streams [Low level and.
Object Persistence and Object serialization CSNB534 Asma Shakil.
Java Programming: Advanced Topics 1 Input/Output and Serialization Chapter 3.
Chapter 3 Inheritance and Polymorphism Goals: 1.Superclasses and subclasses 2.Inheritance Hierarchy 3.Polymorphism 4.Type Compatibility 5.Abstract Classes.
Lecture 19 Serialization Richard Gesick. Serialization Sometimes it is easier to read or write entire objects than to read and write individual fields.
Constructors & Garbage Collection Ch. 9 – Head First Java.
Object Serialization.  When the data was output to disk, certain information was lost, such as the type of each value.  If the value "3" is read from.
Object Serialization. Sequential-access Text Files Sequential-access files store records In order by the record-key field Java imposes no structure on.
©SoftMoore ConsultingSlide 1 Serialization. ©SoftMoore ConsultingSlide 2 Serialization Allows objects to be written to a stream Can be used for persistence.
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
Access Modifiers Control which classes use a feature Only class-level variables may be controlled by access modifiers Modifiers 1. public 2. protected.
CS 116 OBJECT ORIENTED PROGRAMMING II LECTURE 12 GEORGE KOUTSOGIANNAKIS Copyright: 2015 Illinois Institute of Technology/ George Koutsogiannakis 1.
Inheritance and Polymorphism. Superclass and Subclass Inheritance defines a relationship between objects that share characteristics. It is a mechanism.
Spring 2008 Mark Fontenot CSE Honors Principles of Computer Science I Note Set 20.
JAVA: An Introduction to Problem Solving & Programming, 7 th Ed. By Walter Savitch ISBN © 2015 Pearson Education, Inc., Upper Saddle River,
The Memento Pattern (Behavioral) ©SoftMoore ConsultingSlide 1.
JAVA: An Introduction to Problem Solving & Programming, 6 th Ed. By Walter Savitch ISBN © 2012 Pearson Education, Inc., Upper Saddle River,
Files and Serialization. Files Used to transfer data to and from secondary storage.
Simple Java I/O Part I General Principles. Streams All modern I/O is stream-based A stream is a connection to a source of data or to a destination for.
Java Programming: Advanced Topics 1 Input/Output and Serialization.
1 CSE 331 Memento Pattern and Serialization slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer, Wikipedia
Objects and Classes. F OO Programming Concepts F Creating Objects and Object Reference Variables –Differences between primitive data type and object type.
OBJECT ORIENTED PROGRAMMING II LECTURE 21 GEORGE KOUTSOGIANNAKIS
University Of Karachi Department Of Computer Science
Object Writing in files
Object Serialization in Java
Java Primer 1: Types, Classes and Operators
RMI Packages Overview java.rmi java.rmi.server java.rmi.registry
Memento Design Pattern
abstract classes and casting objects
I/O Basics.
Java Serialization B.Ramamurthy 11/8/2018 B.Ramamurthy.
CS240: Advanced Programming Concepts
Java Serialization B.Ramamurthy 11/14/2018 B.Ramamurthy.
Java Programming Language
Packages and Interfaces
Object Serialization Explanation + Example of file + network
Workshop for Programming And Systems Management Teachers
CSE 331 Memento Pattern slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer, Wikipedia
OBJECT ORIENTED PROGRAMMING II LECTURE 22 GEORGE KOUTSOGIANNAKIS
Workshop for Programming And Systems Management Teachers
Podcast Ch23f Title: Serialization
OO Java Programming Input Output.
Presentation transcript:

Serialization and Deserialization Bullet points from Head First Java, Ch. 14 6-Dec-18 serialization.ppt

saving an object between program runs you can save an object’s state by serializing the object to serialize an object, you need an ObjectOutputStream (from the java.io package) streams are either connection or chain streams connection streams can represent a connection to a source or destination typically a file, network socket connection, or the console chain streams cannot connect to a source or destination they must be chained to a connection (or other) stream to serialize an object to a file, make a FileOutputStream and chain it into an ObjectOutputStream to serialize an object, call writeOjbect(theObject) on the ObjectOutputStream you do not need to call any methods on the FileOutputStream 6-Dec-18 serialization.ppt

Serializable interface by default, objects are not serializable to be serialized, an object must implement the Serializable interface Serializable is an empty interface it has no methods that must be implemented its presence is a signal to the runtime that this object can be serialized if a superclass of the class implements Serializable, the subclass can also be serialized even without explicitly declaring implements Serializable 6-Dec-18 serialization.ppt

when an object is serialized, its entire object graph is serialized the object graph when an object is serialized, its entire object graph is serialized including any objects referenced by the serialized object’s instance variables plus any objects those objects reference, and so on if any object in the graph is not serializable, an exception will be thrown at runtime unless the instance variable referring to the un-serializable object is skipped the transient keyword can be used to do mark an instance variable to be skipped an instance variable marked as transient will be restored as null upon deserialization or the default value for a primitive 6-Dec-18 serialization.ppt

the return type of readObject() is Object deserialization using readObject(), read objects in the order in which they were originally written the return type of readObject() is Object deserialized objects must be cast to their original type static variables are not serializable it doesn’t make sense to make static variables part of a particular object’s state, since all objects of that type (made from that class) share only a single static value 6-Dec-18 serialization.ppt

the end of this PowerPoint file Hooray! 6-Dec-18 serialization.ppt