Download presentation
Presentation is loading. Please wait.
1
CSG2H3 Object Oriented Programming
Java I/O
2
Computer and Me
3
Input / Output Input : Keyboard File Output Screen file
4
Java Stream Sequence of data of undetermined length
Input streams move data into a Java program usually from an external source System.in Output streams move data from a Java program to an external target. System.out
5
Java Stream A Java stream is composed of discrete bytes (characters) of data Byte streams Character streams
6
Byte Streams FileInputStream BufferedInputStream InputStream
FilterInputStream DataInputStream Object FileOutputStream BufferedOutputStream OutputStream FilterOutputStream DataOutputStream PrintStream
7
Character Streams BufferedReader Reader InputStreamReader FileReader
Object BufferedWriter writer OutputStreamWriter FileWriter PrintWriter
8
Snippet Code : Write String
9
Snippet Code : Read String
10
CSG2H3 Object Oriented Programming
Object Persistence
11
Object Persistence Persistence is the property of an object through which its existence transcends time (i.e. the object continues to exist after its creator ceases to exist) and/or space (i. e. the objects location moves from the address space in which it was created).
12
Object Persistence the ability of an object to survive the lifetime of the OS process in which it resides relevant for objects with an internal state The state needs to be retained between object deactivation and object activation
13
Live-time Object Illustration
Instantiation Object used in program Some-time Object Saved//Resurect into/from Storage Object destroyed
14
Object Oriented Live as an Object constructor Save as an Object
serializing Read as an Object De-serializing
15
Persistence Object To File
Must be able to transform to binary (implements java.io.Serializable) BinaryStream Using io.stream mechanism FileOutputStream Write Object to File Using method writeObject() in ObjectOutputStream Object in File Open file with FileInputStream class ReadObject in File Using method readObject() in ObjectInputStream Object Object ready to use
16
Snippet Code : Write Object
17
Snippet Code : Read Object
18
Object Relational Mapping
19
Object Relational Mapping
a programming technique for converting data between incompatible type systems in object- oriented programming languages object-oriented (OO) objects are almost always non-scalar values However, many popular database products such as structured query language database management systems (SQL DBMS) can only store and manipulate scalar values
20
Object Relational Mapping
The programmer must either convert the object values into groups of simpler values for storage in the database (and convert them back upon retrieval), or only use simple scalar values within the program. Object-relational mapping is used to implement the first approach
21
Java Hibernate
22
Java Persistence API (JPA)
23
Question?
24
Credits Music : Yonezawa Madoka - Oui! Ai Kotoba (Instrumental)
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.