SlideShare a Scribd company logo
IADCS Diploma Course Input/Output and Serialization U Nyein Oo COO/Director(IT) Myanma Computer Co., Ltd
How the Java Platform Supports I/O The package java.io supports console I/O and file I/O Console I/O is character keyboard input and output without the mouse graphics of a graphical user interface File I/O involves reading and writing data to and from a mass storage device, typically the computer’s hard drive The new I/O (NIO) package java.nio supplements the original I/O package
Programming I/O In stream I/O, characters or bytes are read or written sequentially The Java platform includes two dual hierarchies of classes that support streams:   byte-oriented input and output  character-oriented input and output The class RandomAccessFile is used to read and write arbitrary locations within a file without first having to read or write all the bytes or characters that precede that location
Byte-Oriented Stream Classes
Predefined Stream Objects All Java programs can use three stream objects that are defined in the System class of the java.lang package:  System.in The field System.in is a java.io.BufferedInputStream object   System.out The field System.out is a java.io.PrintStream object System.err The field System.err is a java.io.PrintStream object
Input Methods Input methods of the java.io.InputStream class: int available() void close() void mark( int  readlimit ) boolean markSupported() int read() int read(byte[]  buffer ) int read( byte[]  buffer , int  offset , int  length )  void reset() long skip(long  bytecount )
Output Methods Output methods of the java.io.OutputStream class: void close() void flush() void write( int  b ) void write(byte[]  buffer ) void write( byte[]  buffer , int  offset , int  length )
Other Byte I/O Classes   Extensions of InputStream   include the following classes: The class  ByteArrayInputStream   lets you read an array of bytes as though it were an InputStream   object The class  SequenceInputStream   provides a mechanism for concatenating the data from two or more InputStream   objects into a single, seamless stream The class  PipedInputStream   implements half of a pipe to connect the input stream of one thread or process to the output stream of another thread process
Other Byte I/O Classes   Extensions of OutputStream   include the following classes : The class  ByteArrayOutputStream   sends its output into an object of type byte The class  PipedOutputStream   is the complementary class to PipedInputStream
Parsing an Input Stream The next step after reading a line of input is to parse it, or break it into separate tokens A token usually consists of a sequence of characters that does not include a space, newline, tab, or other nonprinting character To tokenize a string, you can use the  StringTokenizer  class provided by the java.util package
Random-Access File I/O The class RandomAccessFile supports byte-oriented I/O to and from random-access files The class RandomAccessFile extends Object RandomAccessFile combines input and output operations in one class The seek method selects the position within the file where the next I/O operation will begin
Character Streams
Connecting Byte & Character I/O Classes The Java platform includes adapter classes that bridge between character I/O classes and byte I/O classes : InputStreamReader OutputStreamWriter
Using Other Character I/O Classes Extensions of the Reader   object include the following: The class  CharArrayReader   lets you read an array of characters as though it were a Reader object The class  StringReader   lets you read a String object as though it were a Reader object The class  PipedReader   implements half of a pipe and is especially useful for communication between threads.
Using Other Character I/O Classes Extensions of the Writer   object include the following: The class  CharArrayWriter   sends its output into an object of type char[] The class  StringWriter   lets you write to a StringBuffer object as though it were a Writer   object The class  PipedWriter   is the complementary class to PipedReader The class  PrintWriter   is the character I/O equivalent of the PrintStream class
The New I/O (NIO) Interface The java.nio package provides new features : Support for buffer management A new primitive I/O abstraction called a channel File locking at the process level Memory mapping
Buffers Capacity:  the maximum number of data elements that the buffer can contain Limit : a reflection of the amount of data that the buffer currently contains and is defined as the index of the first element in the buffer that should not be read or written Mark : the index to which the position value will be set if the buffer is reset  Position : the index of the next element to be read or written and can never exceed the limit
Buffer Classes in java.nio
Object Serialization  Object serialization :   a general solution that lets you write objects to I/O streams and then read them, without defining any additional methods Enables t ransmission of objects over a network or save objects to files between runs of your program The object serialization feature is an important component of the Java Remote Method Invocation (RMI) enterprise API
Using Object Streams Two stream classes support object serialization:  ObjectOutputStream  - a subclass of OutputStream ObjectInputStream  - a subclass of InputStream To create an  ObjectOutputStream object, provide an existing OutputStream object as the argument of the constructor To create an ObjectInputStream object, provide an existing InputStream object as the argument of the constructor
Suppressing Serialization of Fields Include the qualifier transient when you declare fields to indicate that they should not be serialized with instances of the class Fields that have the transient qualifier are not output when the object is serialized When the object is deserialized later, transient fields are given the default value normally used for fields of their type
Ad

More Related Content

What's hot (20)

java.io - streams and files
java.io - streams and filesjava.io - streams and files
java.io - streams and files
Marcello Thiry
 
Io Streams
Io StreamsIo Streams
Io Streams
phanleson
 
Java IO
Java IOJava IO
Java IO
UTSAB NEUPANE
 
Javaiostream
JavaiostreamJavaiostream
Javaiostream
Tien Nguyen
 
Character stream classes introd .51
Character stream classes introd  .51Character stream classes introd  .51
Character stream classes introd .51
myrajendra
 
Java I/o streams
Java I/o streamsJava I/o streams
Java I/o streams
Hamid Ghorbani
 
Java Course 8: I/O, Files and Streams
Java Course 8: I/O, Files and StreamsJava Course 8: I/O, Files and Streams
Java Course 8: I/O, Files and Streams
Anton Keks
 
L21 io streams
L21 io streamsL21 io streams
L21 io streams
teach4uin
 
Java program file I/O
Java program file I/OJava program file I/O
Java program file I/O
Nem Sothea
 
input/ output in java
input/ output  in javainput/ output  in java
input/ output in java
sharma230399
 
Java - File Input Output Concepts
Java - File Input Output ConceptsJava - File Input Output Concepts
Java - File Input Output Concepts
Victer Paul
 
Character stream classes .52
Character stream classes .52Character stream classes .52
Character stream classes .52
myrajendra
 
Handling I/O in Java
Handling I/O in JavaHandling I/O in Java
Handling I/O in Java
Hiranya Jayathilaka
 
Java IO Package and Streams
Java IO Package and StreamsJava IO Package and Streams
Java IO Package and Streams
babak danyal
 
Basic i/o & file handling in java
Basic i/o & file handling in javaBasic i/o & file handling in java
Basic i/o & file handling in java
JayasankarPR2
 
Files in java
Files in javaFiles in java
Files in java
Muthukumaran Subramanian
 
32.java input-output
32.java input-output32.java input-output
32.java input-output
santosh mishra
 
Oodp mod4
Oodp mod4Oodp mod4
Oodp mod4
cs19club
 
File Handling in Java Oop presentation
File Handling in Java Oop presentationFile Handling in Java Oop presentation
File Handling in Java Oop presentation
Azeemaj101
 
Io Streams
Io StreamsIo Streams
Io Streams
leminhvuong
 
java.io - streams and files
java.io - streams and filesjava.io - streams and files
java.io - streams and files
Marcello Thiry
 
Character stream classes introd .51
Character stream classes introd  .51Character stream classes introd  .51
Character stream classes introd .51
myrajendra
 
Java Course 8: I/O, Files and Streams
Java Course 8: I/O, Files and StreamsJava Course 8: I/O, Files and Streams
Java Course 8: I/O, Files and Streams
Anton Keks
 
L21 io streams
L21 io streamsL21 io streams
L21 io streams
teach4uin
 
Java program file I/O
Java program file I/OJava program file I/O
Java program file I/O
Nem Sothea
 
input/ output in java
input/ output  in javainput/ output  in java
input/ output in java
sharma230399
 
Java - File Input Output Concepts
Java - File Input Output ConceptsJava - File Input Output Concepts
Java - File Input Output Concepts
Victer Paul
 
Character stream classes .52
Character stream classes .52Character stream classes .52
Character stream classes .52
myrajendra
 
Java IO Package and Streams
Java IO Package and StreamsJava IO Package and Streams
Java IO Package and Streams
babak danyal
 
Basic i/o & file handling in java
Basic i/o & file handling in javaBasic i/o & file handling in java
Basic i/o & file handling in java
JayasankarPR2
 
File Handling in Java Oop presentation
File Handling in Java Oop presentationFile Handling in Java Oop presentation
File Handling in Java Oop presentation
Azeemaj101
 

Viewers also liked (20)

Elasticsearch Aggregations
Elasticsearch AggregationsElasticsearch Aggregations
Elasticsearch Aggregations
Waldemar Neto
 
Object to input stream transformer
Object to input stream transformerObject to input stream transformer
Object to input stream transformer
Rahul Kumar
 
Java Serialization
Java SerializationJava Serialization
Java Serialization
imypraz
 
Threadlifecycle.36
Threadlifecycle.36Threadlifecycle.36
Threadlifecycle.36
myrajendra
 
Remote method invocation (as part of the the PTT lecture)
Remote method invocation (as part of the the PTT lecture)Remote method invocation (as part of the the PTT lecture)
Remote method invocation (as part of the the PTT lecture)
Ralf Laemmel
 
Javaiostream
JavaiostreamJavaiostream
Javaiostream
Manav Prasad
 
enterprise java bean
enterprise java beanenterprise java bean
enterprise java bean
Jitender Singh Lodhi
 
Ejb 2.0
Ejb 2.0Ejb 2.0
Ejb 2.0
sukace
 
Itp 120 Chapt 19 2009 Binary Input & Output
Itp 120 Chapt 19 2009 Binary Input & OutputItp 120 Chapt 19 2009 Binary Input & Output
Itp 120 Chapt 19 2009 Binary Input & Output
phanleson
 
Io stream
Io streamIo stream
Io stream
Parthipan Parthi
 
Servlet/JSP course chapter 1: Introduction to servlets
Servlet/JSP course chapter 1: Introduction to servletsServlet/JSP course chapter 1: Introduction to servlets
Servlet/JSP course chapter 1: Introduction to servlets
JavaEE Trainers
 
Java Serialization
Java SerializationJava Serialization
Java Serialization
jeslie
 
Md121 streams
Md121 streamsMd121 streams
Md121 streams
Rakesh Madugula
 
Java exception
Java exception Java exception
Java exception
Arati Gadgil
 
Remote Method Invocation
Remote Method InvocationRemote Method Invocation
Remote Method Invocation
Paul Pajo
 
Java EE 8: What Servlet 4.0 and HTTP/2 mean to you
Java EE 8: What Servlet 4.0 and HTTP/2 mean to youJava EE 8: What Servlet 4.0 and HTTP/2 mean to you
Java EE 8: What Servlet 4.0 and HTTP/2 mean to you
Alex Theedom
 
Serialization/deserialization
Serialization/deserializationSerialization/deserialization
Serialization/deserialization
Young Alista
 
Thread Dump Analysis
Thread Dump AnalysisThread Dump Analysis
Thread Dump Analysis
Dmitry Buzdin
 
Java Multi Thead Programming
Java Multi Thead ProgrammingJava Multi Thead Programming
Java Multi Thead Programming
Nishant Mevawala
 
Java bean
Java beanJava bean
Java bean
Jafar Nesargi
 
Elasticsearch Aggregations
Elasticsearch AggregationsElasticsearch Aggregations
Elasticsearch Aggregations
Waldemar Neto
 
Object to input stream transformer
Object to input stream transformerObject to input stream transformer
Object to input stream transformer
Rahul Kumar
 
Java Serialization
Java SerializationJava Serialization
Java Serialization
imypraz
 
Threadlifecycle.36
Threadlifecycle.36Threadlifecycle.36
Threadlifecycle.36
myrajendra
 
Remote method invocation (as part of the the PTT lecture)
Remote method invocation (as part of the the PTT lecture)Remote method invocation (as part of the the PTT lecture)
Remote method invocation (as part of the the PTT lecture)
Ralf Laemmel
 
Ejb 2.0
Ejb 2.0Ejb 2.0
Ejb 2.0
sukace
 
Itp 120 Chapt 19 2009 Binary Input & Output
Itp 120 Chapt 19 2009 Binary Input & OutputItp 120 Chapt 19 2009 Binary Input & Output
Itp 120 Chapt 19 2009 Binary Input & Output
phanleson
 
Servlet/JSP course chapter 1: Introduction to servlets
Servlet/JSP course chapter 1: Introduction to servletsServlet/JSP course chapter 1: Introduction to servlets
Servlet/JSP course chapter 1: Introduction to servlets
JavaEE Trainers
 
Java Serialization
Java SerializationJava Serialization
Java Serialization
jeslie
 
Remote Method Invocation
Remote Method InvocationRemote Method Invocation
Remote Method Invocation
Paul Pajo
 
Java EE 8: What Servlet 4.0 and HTTP/2 mean to you
Java EE 8: What Servlet 4.0 and HTTP/2 mean to youJava EE 8: What Servlet 4.0 and HTTP/2 mean to you
Java EE 8: What Servlet 4.0 and HTTP/2 mean to you
Alex Theedom
 
Serialization/deserialization
Serialization/deserializationSerialization/deserialization
Serialization/deserialization
Young Alista
 
Thread Dump Analysis
Thread Dump AnalysisThread Dump Analysis
Thread Dump Analysis
Dmitry Buzdin
 
Java Multi Thead Programming
Java Multi Thead ProgrammingJava Multi Thead Programming
Java Multi Thead Programming
Nishant Mevawala
 
Ad

Similar to IO and serialization (20)

Unit IV Notes.docx
Unit IV Notes.docxUnit IV Notes.docx
Unit IV Notes.docx
GayathriRHICETCSESTA
 
UNIT4-IO,Generics,String Handling.pdf Notes
UNIT4-IO,Generics,String Handling.pdf NotesUNIT4-IO,Generics,String Handling.pdf Notes
UNIT4-IO,Generics,String Handling.pdf Notes
SakkaravarthiS1
 
Java programming Chapter 4.pptx
Java programming Chapter 4.pptxJava programming Chapter 4.pptx
Java programming Chapter 4.pptx
ssusera0d3d2
 
Java IO Stream, the introduction to Streams
Java IO Stream, the introduction to StreamsJava IO Stream, the introduction to Streams
Java IO Stream, the introduction to Streams
ranganadh6
 
Java I/O and Object Serialization
Java I/O and Object SerializationJava I/O and Object Serialization
Java I/O and Object Serialization
Navneet Prakash
 
Java Input and Output
Java Input and OutputJava Input and Output
Java Input and Output
Ducat India
 
file handling in object oriented programming through java
file handling in object oriented programming through javafile handling in object oriented programming through java
file handling in object oriented programming through java
Parameshwar Maddela
 
Computer science input and output BASICS.pptx
Computer science input and output BASICS.pptxComputer science input and output BASICS.pptx
Computer science input and output BASICS.pptx
RathanMB
 
Java development development Files lectur6.ppt
Java development development Files lectur6.pptJava development development Files lectur6.ppt
Java development development Files lectur6.ppt
rafeakrafeak
 
Lecture 23
Lecture 23Lecture 23
Lecture 23
Debasish Pratihari
 
Buffer and scanner
Buffer and scannerBuffer and scanner
Buffer and scanner
Arif Ullah
 
Jedi Slides Intro2 Chapter12 Advanced Io Streams
Jedi Slides Intro2 Chapter12 Advanced Io StreamsJedi Slides Intro2 Chapter12 Advanced Io Streams
Jedi Slides Intro2 Chapter12 Advanced Io Streams
Don Bosco BSIT
 
Iostreams
IostreamsIostreams
Iostreams
aptechsravan
 
Unit No 5 Files and Database Connectivity.pptx
Unit No 5 Files and Database Connectivity.pptxUnit No 5 Files and Database Connectivity.pptx
Unit No 5 Files and Database Connectivity.pptx
DrYogeshDeshmukh1
 
Web Technology Web Technology Notes Streams Network Principles and SocketsUni...
Web Technology Web Technology Notes Streams Network Principles and SocketsUni...Web Technology Web Technology Notes Streams Network Principles and SocketsUni...
Web Technology Web Technology Notes Streams Network Principles and SocketsUni...
uthayashangar1
 
I/O Streams
I/O StreamsI/O Streams
I/O Streams
Ravi Chythanya
 
Java Day-6
Java Day-6Java Day-6
Java Day-6
People Strategists
 
Stream In Java.pptx
Stream In Java.pptxStream In Java.pptx
Stream In Java.pptx
ssuser9d7049
 
CHAPTER 5 mechanical engineeringasaaa.pptx
CHAPTER 5 mechanical engineeringasaaa.pptxCHAPTER 5 mechanical engineeringasaaa.pptx
CHAPTER 5 mechanical engineeringasaaa.pptx
SadhilAggarwal
 
Java session08
Java session08Java session08
Java session08
Niit Care
 
UNIT4-IO,Generics,String Handling.pdf Notes
UNIT4-IO,Generics,String Handling.pdf NotesUNIT4-IO,Generics,String Handling.pdf Notes
UNIT4-IO,Generics,String Handling.pdf Notes
SakkaravarthiS1
 
Java programming Chapter 4.pptx
Java programming Chapter 4.pptxJava programming Chapter 4.pptx
Java programming Chapter 4.pptx
ssusera0d3d2
 
Java IO Stream, the introduction to Streams
Java IO Stream, the introduction to StreamsJava IO Stream, the introduction to Streams
Java IO Stream, the introduction to Streams
ranganadh6
 
Java I/O and Object Serialization
Java I/O and Object SerializationJava I/O and Object Serialization
Java I/O and Object Serialization
Navneet Prakash
 
Java Input and Output
Java Input and OutputJava Input and Output
Java Input and Output
Ducat India
 
file handling in object oriented programming through java
file handling in object oriented programming through javafile handling in object oriented programming through java
file handling in object oriented programming through java
Parameshwar Maddela
 
Computer science input and output BASICS.pptx
Computer science input and output BASICS.pptxComputer science input and output BASICS.pptx
Computer science input and output BASICS.pptx
RathanMB
 
Java development development Files lectur6.ppt
Java development development Files lectur6.pptJava development development Files lectur6.ppt
Java development development Files lectur6.ppt
rafeakrafeak
 
Buffer and scanner
Buffer and scannerBuffer and scanner
Buffer and scanner
Arif Ullah
 
Jedi Slides Intro2 Chapter12 Advanced Io Streams
Jedi Slides Intro2 Chapter12 Advanced Io StreamsJedi Slides Intro2 Chapter12 Advanced Io Streams
Jedi Slides Intro2 Chapter12 Advanced Io Streams
Don Bosco BSIT
 
Unit No 5 Files and Database Connectivity.pptx
Unit No 5 Files and Database Connectivity.pptxUnit No 5 Files and Database Connectivity.pptx
Unit No 5 Files and Database Connectivity.pptx
DrYogeshDeshmukh1
 
Web Technology Web Technology Notes Streams Network Principles and SocketsUni...
Web Technology Web Technology Notes Streams Network Principles and SocketsUni...Web Technology Web Technology Notes Streams Network Principles and SocketsUni...
Web Technology Web Technology Notes Streams Network Principles and SocketsUni...
uthayashangar1
 
Stream In Java.pptx
Stream In Java.pptxStream In Java.pptx
Stream In Java.pptx
ssuser9d7049
 
CHAPTER 5 mechanical engineeringasaaa.pptx
CHAPTER 5 mechanical engineeringasaaa.pptxCHAPTER 5 mechanical engineeringasaaa.pptx
CHAPTER 5 mechanical engineeringasaaa.pptx
SadhilAggarwal
 
Java session08
Java session08Java session08
Java session08
Niit Care
 
Ad

More from backdoor (20)

Java Database Connectivity
Java Database ConnectivityJava Database Connectivity
Java Database Connectivity
backdoor
 
Distributed Programming using RMI
 Distributed Programming using RMI Distributed Programming using RMI
Distributed Programming using RMI
backdoor
 
Programming Server side with Sevlet
 Programming Server side with Sevlet  Programming Server side with Sevlet
Programming Server side with Sevlet
backdoor
 
Distributed Programming using RMI
Distributed Programming using RMIDistributed Programming using RMI
Distributed Programming using RMI
backdoor
 
Client Side Programming with Applet
Client Side Programming with AppletClient Side Programming with Applet
Client Side Programming with Applet
backdoor
 
Java Network Programming
Java Network ProgrammingJava Network Programming
Java Network Programming
backdoor
 
Windows Programming with Swing
Windows Programming with SwingWindows Programming with Swing
Windows Programming with Swing
backdoor
 
Windows Programming with AWT
Windows Programming with AWTWindows Programming with AWT
Windows Programming with AWT
backdoor
 
Multithreading
MultithreadingMultithreading
Multithreading
backdoor
 
Object and Classes in Java
Object and Classes in JavaObject and Classes in Java
Object and Classes in Java
backdoor
 
Exception Handling
Exception HandlingException Handling
Exception Handling
backdoor
 
Java Intro
Java IntroJava Intro
Java Intro
backdoor
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Java
backdoor
 
AWT Program output
AWT Program outputAWT Program output
AWT Program output
backdoor
 
Net Man
Net ManNet Man
Net Man
backdoor
 
Data Security
Data SecurityData Security
Data Security
backdoor
 
Ne Course Part One
Ne Course Part OneNe Course Part One
Ne Course Part One
backdoor
 
Ne Course Part Two
Ne Course Part TwoNe Course Part Two
Ne Course Part Two
backdoor
 
Net Sec
Net SecNet Sec
Net Sec
backdoor
 
Security Policy Checklist
Security Policy ChecklistSecurity Policy Checklist
Security Policy Checklist
backdoor
 
Java Database Connectivity
Java Database ConnectivityJava Database Connectivity
Java Database Connectivity
backdoor
 
Distributed Programming using RMI
 Distributed Programming using RMI Distributed Programming using RMI
Distributed Programming using RMI
backdoor
 
Programming Server side with Sevlet
 Programming Server side with Sevlet  Programming Server side with Sevlet
Programming Server side with Sevlet
backdoor
 
Distributed Programming using RMI
Distributed Programming using RMIDistributed Programming using RMI
Distributed Programming using RMI
backdoor
 
Client Side Programming with Applet
Client Side Programming with AppletClient Side Programming with Applet
Client Side Programming with Applet
backdoor
 
Java Network Programming
Java Network ProgrammingJava Network Programming
Java Network Programming
backdoor
 
Windows Programming with Swing
Windows Programming with SwingWindows Programming with Swing
Windows Programming with Swing
backdoor
 
Windows Programming with AWT
Windows Programming with AWTWindows Programming with AWT
Windows Programming with AWT
backdoor
 
Multithreading
MultithreadingMultithreading
Multithreading
backdoor
 
Object and Classes in Java
Object and Classes in JavaObject and Classes in Java
Object and Classes in Java
backdoor
 
Exception Handling
Exception HandlingException Handling
Exception Handling
backdoor
 
Java Intro
Java IntroJava Intro
Java Intro
backdoor
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Java
backdoor
 
AWT Program output
AWT Program outputAWT Program output
AWT Program output
backdoor
 
Data Security
Data SecurityData Security
Data Security
backdoor
 
Ne Course Part One
Ne Course Part OneNe Course Part One
Ne Course Part One
backdoor
 
Ne Course Part Two
Ne Course Part TwoNe Course Part Two
Ne Course Part Two
backdoor
 
Security Policy Checklist
Security Policy ChecklistSecurity Policy Checklist
Security Policy Checklist
backdoor
 

Recently uploaded (20)

From Dreams to Threads: The Story Behind The Chhapai
From Dreams to Threads: The Story Behind The ChhapaiFrom Dreams to Threads: The Story Behind The Chhapai
From Dreams to Threads: The Story Behind The Chhapai
The Chhapai
 
Affinity.co Lifecycle Marketing Presentation
Affinity.co Lifecycle Marketing PresentationAffinity.co Lifecycle Marketing Presentation
Affinity.co Lifecycle Marketing Presentation
omiller199514
 
TMG - Q3 2025 Earnings Call Slides - v4.pptx
TMG - Q3 2025 Earnings Call Slides - v4.pptxTMG - Q3 2025 Earnings Call Slides - v4.pptx
TMG - Q3 2025 Earnings Call Slides - v4.pptx
Marketing847413
 
www.visualmedia.com digital markiting (1).pptx
www.visualmedia.com digital markiting (1).pptxwww.visualmedia.com digital markiting (1).pptx
www.visualmedia.com digital markiting (1).pptx
Davinder Singh
 
INTRODUCTION OF MANAGEMENT.pdf CA SUVIDHA CHAPLOT
INTRODUCTION OF MANAGEMENT.pdf CA SUVIDHA CHAPLOTINTRODUCTION OF MANAGEMENT.pdf CA SUVIDHA CHAPLOT
INTRODUCTION OF MANAGEMENT.pdf CA SUVIDHA CHAPLOT
CA Suvidha Chaplot
 
Region Research (Hiring Trends) Vietnam 2025.pdf
Region Research (Hiring Trends) Vietnam 2025.pdfRegion Research (Hiring Trends) Vietnam 2025.pdf
Region Research (Hiring Trends) Vietnam 2025.pdf
Consultonmic
 
Looking for Reliable BPO Project Providers?"
Looking for Reliable BPO Project Providers?"Looking for Reliable BPO Project Providers?"
Looking for Reliable BPO Project Providers?"
anujascentbpo
 
Strategic Enterprise Management - Unit I.pptx
Strategic Enterprise Management - Unit I.pptxStrategic Enterprise Management - Unit I.pptx
Strategic Enterprise Management - Unit I.pptx
PrekshyaRana
 
Avoiding the China Tariffs: Save Costs & Stay Competitive
Avoiding the China Tariffs: Save Costs & Stay CompetitiveAvoiding the China Tariffs: Save Costs & Stay Competitive
Avoiding the China Tariffs: Save Costs & Stay Competitive
NovaLink
 
Salesforce_Architecture_Diagramming_Workshop (1).pptx
Salesforce_Architecture_Diagramming_Workshop (1).pptxSalesforce_Architecture_Diagramming_Workshop (1).pptx
Salesforce_Architecture_Diagramming_Workshop (1).pptx
reinbauwens1
 
BeMetals_Presentation_May_2025 .pdf
BeMetals_Presentation_May_2025      .pdfBeMetals_Presentation_May_2025      .pdf
BeMetals_Presentation_May_2025 .pdf
DerekIwanaka2
 
LDMMIA Bday celebration 2025 Gifts information
LDMMIA Bday celebration 2025 Gifts informationLDMMIA Bday celebration 2025 Gifts information
LDMMIA Bday celebration 2025 Gifts information
LDM Mia eStudios
 
20250428 CDB Investor Deck_Apr25_vFF.pdf
20250428 CDB Investor Deck_Apr25_vFF.pdf20250428 CDB Investor Deck_Apr25_vFF.pdf
20250428 CDB Investor Deck_Apr25_vFF.pdf
yihong30
 
Freeze-Dried Fruit Powder Market Trends & Growth
Freeze-Dried Fruit Powder Market Trends & GrowthFreeze-Dried Fruit Powder Market Trends & Growth
Freeze-Dried Fruit Powder Market Trends & Growth
chanderdeepseoexpert
 
Accounting_Basics_Complete_Guide_By_CA_Suvidha_Chaplot (1).pdf
Accounting_Basics_Complete_Guide_By_CA_Suvidha_Chaplot (1).pdfAccounting_Basics_Complete_Guide_By_CA_Suvidha_Chaplot (1).pdf
Accounting_Basics_Complete_Guide_By_CA_Suvidha_Chaplot (1).pdf
CA Suvidha Chaplot
 
intra-mart Accel series 2025 Spring updates-en.ppt
intra-mart Accel series 2025 Spring updates-en.pptintra-mart Accel series 2025 Spring updates-en.ppt
intra-mart Accel series 2025 Spring updates-en.ppt
NTTDATA INTRAMART
 
The Rise of Payroll Outsourcing in the UK: Key Statistics for 2025
The Rise of Payroll Outsourcing in the UK: Key Statistics for 2025The Rise of Payroll Outsourcing in the UK: Key Statistics for 2025
The Rise of Payroll Outsourcing in the UK: Key Statistics for 2025
QX Accounting Services Ltd
 
Kiran Flemish - A Dynamic Musician
Kiran  Flemish  -  A   Dynamic  MusicianKiran  Flemish  -  A   Dynamic  Musician
Kiran Flemish - A Dynamic Musician
Kiran Flemish
 
Alan Stalcup - The Enterprising CEO
Alan  Stalcup  -  The  Enterprising  CEOAlan  Stalcup  -  The  Enterprising  CEO
Alan Stalcup - The Enterprising CEO
Alan Stalcup
 
EquariusAI analytics for business water risk
EquariusAI analytics for business water riskEquariusAI analytics for business water risk
EquariusAI analytics for business water risk
Peter Adriaens
 
From Dreams to Threads: The Story Behind The Chhapai
From Dreams to Threads: The Story Behind The ChhapaiFrom Dreams to Threads: The Story Behind The Chhapai
From Dreams to Threads: The Story Behind The Chhapai
The Chhapai
 
Affinity.co Lifecycle Marketing Presentation
Affinity.co Lifecycle Marketing PresentationAffinity.co Lifecycle Marketing Presentation
Affinity.co Lifecycle Marketing Presentation
omiller199514
 
TMG - Q3 2025 Earnings Call Slides - v4.pptx
TMG - Q3 2025 Earnings Call Slides - v4.pptxTMG - Q3 2025 Earnings Call Slides - v4.pptx
TMG - Q3 2025 Earnings Call Slides - v4.pptx
Marketing847413
 
www.visualmedia.com digital markiting (1).pptx
www.visualmedia.com digital markiting (1).pptxwww.visualmedia.com digital markiting (1).pptx
www.visualmedia.com digital markiting (1).pptx
Davinder Singh
 
INTRODUCTION OF MANAGEMENT.pdf CA SUVIDHA CHAPLOT
INTRODUCTION OF MANAGEMENT.pdf CA SUVIDHA CHAPLOTINTRODUCTION OF MANAGEMENT.pdf CA SUVIDHA CHAPLOT
INTRODUCTION OF MANAGEMENT.pdf CA SUVIDHA CHAPLOT
CA Suvidha Chaplot
 
Region Research (Hiring Trends) Vietnam 2025.pdf
Region Research (Hiring Trends) Vietnam 2025.pdfRegion Research (Hiring Trends) Vietnam 2025.pdf
Region Research (Hiring Trends) Vietnam 2025.pdf
Consultonmic
 
Looking for Reliable BPO Project Providers?"
Looking for Reliable BPO Project Providers?"Looking for Reliable BPO Project Providers?"
Looking for Reliable BPO Project Providers?"
anujascentbpo
 
Strategic Enterprise Management - Unit I.pptx
Strategic Enterprise Management - Unit I.pptxStrategic Enterprise Management - Unit I.pptx
Strategic Enterprise Management - Unit I.pptx
PrekshyaRana
 
Avoiding the China Tariffs: Save Costs & Stay Competitive
Avoiding the China Tariffs: Save Costs & Stay CompetitiveAvoiding the China Tariffs: Save Costs & Stay Competitive
Avoiding the China Tariffs: Save Costs & Stay Competitive
NovaLink
 
Salesforce_Architecture_Diagramming_Workshop (1).pptx
Salesforce_Architecture_Diagramming_Workshop (1).pptxSalesforce_Architecture_Diagramming_Workshop (1).pptx
Salesforce_Architecture_Diagramming_Workshop (1).pptx
reinbauwens1
 
BeMetals_Presentation_May_2025 .pdf
BeMetals_Presentation_May_2025      .pdfBeMetals_Presentation_May_2025      .pdf
BeMetals_Presentation_May_2025 .pdf
DerekIwanaka2
 
LDMMIA Bday celebration 2025 Gifts information
LDMMIA Bday celebration 2025 Gifts informationLDMMIA Bday celebration 2025 Gifts information
LDMMIA Bday celebration 2025 Gifts information
LDM Mia eStudios
 
20250428 CDB Investor Deck_Apr25_vFF.pdf
20250428 CDB Investor Deck_Apr25_vFF.pdf20250428 CDB Investor Deck_Apr25_vFF.pdf
20250428 CDB Investor Deck_Apr25_vFF.pdf
yihong30
 
Freeze-Dried Fruit Powder Market Trends & Growth
Freeze-Dried Fruit Powder Market Trends & GrowthFreeze-Dried Fruit Powder Market Trends & Growth
Freeze-Dried Fruit Powder Market Trends & Growth
chanderdeepseoexpert
 
Accounting_Basics_Complete_Guide_By_CA_Suvidha_Chaplot (1).pdf
Accounting_Basics_Complete_Guide_By_CA_Suvidha_Chaplot (1).pdfAccounting_Basics_Complete_Guide_By_CA_Suvidha_Chaplot (1).pdf
Accounting_Basics_Complete_Guide_By_CA_Suvidha_Chaplot (1).pdf
CA Suvidha Chaplot
 
intra-mart Accel series 2025 Spring updates-en.ppt
intra-mart Accel series 2025 Spring updates-en.pptintra-mart Accel series 2025 Spring updates-en.ppt
intra-mart Accel series 2025 Spring updates-en.ppt
NTTDATA INTRAMART
 
The Rise of Payroll Outsourcing in the UK: Key Statistics for 2025
The Rise of Payroll Outsourcing in the UK: Key Statistics for 2025The Rise of Payroll Outsourcing in the UK: Key Statistics for 2025
The Rise of Payroll Outsourcing in the UK: Key Statistics for 2025
QX Accounting Services Ltd
 
Kiran Flemish - A Dynamic Musician
Kiran  Flemish  -  A   Dynamic  MusicianKiran  Flemish  -  A   Dynamic  Musician
Kiran Flemish - A Dynamic Musician
Kiran Flemish
 
Alan Stalcup - The Enterprising CEO
Alan  Stalcup  -  The  Enterprising  CEOAlan  Stalcup  -  The  Enterprising  CEO
Alan Stalcup - The Enterprising CEO
Alan Stalcup
 
EquariusAI analytics for business water risk
EquariusAI analytics for business water riskEquariusAI analytics for business water risk
EquariusAI analytics for business water risk
Peter Adriaens
 

IO and serialization

  • 1. IADCS Diploma Course Input/Output and Serialization U Nyein Oo COO/Director(IT) Myanma Computer Co., Ltd
  • 2. How the Java Platform Supports I/O The package java.io supports console I/O and file I/O Console I/O is character keyboard input and output without the mouse graphics of a graphical user interface File I/O involves reading and writing data to and from a mass storage device, typically the computer’s hard drive The new I/O (NIO) package java.nio supplements the original I/O package
  • 3. Programming I/O In stream I/O, characters or bytes are read or written sequentially The Java platform includes two dual hierarchies of classes that support streams: byte-oriented input and output character-oriented input and output The class RandomAccessFile is used to read and write arbitrary locations within a file without first having to read or write all the bytes or characters that precede that location
  • 5. Predefined Stream Objects All Java programs can use three stream objects that are defined in the System class of the java.lang package: System.in The field System.in is a java.io.BufferedInputStream object System.out The field System.out is a java.io.PrintStream object System.err The field System.err is a java.io.PrintStream object
  • 6. Input Methods Input methods of the java.io.InputStream class: int available() void close() void mark( int readlimit ) boolean markSupported() int read() int read(byte[] buffer ) int read( byte[] buffer , int offset , int length ) void reset() long skip(long bytecount )
  • 7. Output Methods Output methods of the java.io.OutputStream class: void close() void flush() void write( int b ) void write(byte[] buffer ) void write( byte[] buffer , int offset , int length )
  • 8. Other Byte I/O Classes Extensions of InputStream include the following classes: The class ByteArrayInputStream lets you read an array of bytes as though it were an InputStream object The class SequenceInputStream provides a mechanism for concatenating the data from two or more InputStream objects into a single, seamless stream The class PipedInputStream implements half of a pipe to connect the input stream of one thread or process to the output stream of another thread process
  • 9. Other Byte I/O Classes Extensions of OutputStream include the following classes : The class ByteArrayOutputStream sends its output into an object of type byte The class PipedOutputStream is the complementary class to PipedInputStream
  • 10. Parsing an Input Stream The next step after reading a line of input is to parse it, or break it into separate tokens A token usually consists of a sequence of characters that does not include a space, newline, tab, or other nonprinting character To tokenize a string, you can use the StringTokenizer class provided by the java.util package
  • 11. Random-Access File I/O The class RandomAccessFile supports byte-oriented I/O to and from random-access files The class RandomAccessFile extends Object RandomAccessFile combines input and output operations in one class The seek method selects the position within the file where the next I/O operation will begin
  • 13. Connecting Byte & Character I/O Classes The Java platform includes adapter classes that bridge between character I/O classes and byte I/O classes : InputStreamReader OutputStreamWriter
  • 14. Using Other Character I/O Classes Extensions of the Reader object include the following: The class CharArrayReader lets you read an array of characters as though it were a Reader object The class StringReader lets you read a String object as though it were a Reader object The class PipedReader implements half of a pipe and is especially useful for communication between threads.
  • 15. Using Other Character I/O Classes Extensions of the Writer object include the following: The class CharArrayWriter sends its output into an object of type char[] The class StringWriter lets you write to a StringBuffer object as though it were a Writer object The class PipedWriter is the complementary class to PipedReader The class PrintWriter is the character I/O equivalent of the PrintStream class
  • 16. The New I/O (NIO) Interface The java.nio package provides new features : Support for buffer management A new primitive I/O abstraction called a channel File locking at the process level Memory mapping
  • 17. Buffers Capacity: the maximum number of data elements that the buffer can contain Limit : a reflection of the amount of data that the buffer currently contains and is defined as the index of the first element in the buffer that should not be read or written Mark : the index to which the position value will be set if the buffer is reset  Position : the index of the next element to be read or written and can never exceed the limit
  • 18. Buffer Classes in java.nio
  • 19. Object Serialization Object serialization : a general solution that lets you write objects to I/O streams and then read them, without defining any additional methods Enables t ransmission of objects over a network or save objects to files between runs of your program The object serialization feature is an important component of the Java Remote Method Invocation (RMI) enterprise API
  • 20. Using Object Streams Two stream classes support object serialization: ObjectOutputStream - a subclass of OutputStream ObjectInputStream - a subclass of InputStream To create an ObjectOutputStream object, provide an existing OutputStream object as the argument of the constructor To create an ObjectInputStream object, provide an existing InputStream object as the argument of the constructor
  • 21. Suppressing Serialization of Fields Include the qualifier transient when you declare fields to indicate that they should not be serialized with instances of the class Fields that have the transient qualifier are not output when the object is serialized When the object is deserialized later, transient fields are given the default value normally used for fields of their type