SlideShare a Scribd company logo
2
Most read
3
Most read
4
Most read
Java I/O Package
Introduction
• Most programs cannot accomplish their goals without
accessing external data
• Data is retrieved from an input source and results of a
program are sent to an output destination
• These sources or destinations are defined very broadly in
Java, e.g. a network connection, memory buffer, or disk file
• The java.io package supports Java’s basic I/O (input/output)
system
• Java provides strong, flexible support for I/O as it relates to
files and networks
• physically different, these devices are all handled by the
same abstraction: the stream
Streams
• A stream is a logical entity that either produces or
consumes information
• A stream is linked to a physical device by the Java
I/O system
• All streams behave in the same manner, even if the
actual physical devices they are linked to differ
• an input stream can abstract many different kinds of
input: from a disk file, a keyboard, or a network
socket
• Likewise, an output stream may refer to the console,
a disk file, or a network connection
Types of Streams
• Java 2 defines two types of streams: byte and
character
• Byte streams provide a convenient means for
handling input and output of bytes
• Byte streams are used when reading or writing
binary data
• Character streams provide a convenient means
for handling input and output of characters
• They use Unicode and, therefore, can be
internationalized.
Byte Streams
• Byte Streams are defined by using two class
hierarchies
• At the top are two abstract classes:
InputStream and OutputStream
• Each of these abstract classes has several
concrete subclasses
• These classes handle the differences between
various devices, such as disk files, network
connections, and even memory buffers
Byte Streams (contd)
• The abstract classes InputStream and
OutputStream define several key methods
that the other stream classes implement
• Two of the most important are read( ) and
write( ) which read and write bytes of data
• Both methods are declared as abstract and
are overridden by derived stream classes
Character Streams
• Character streams are defined by using two class
hierarchies
• At the top are two abstract classes, Reader and Writer
• These abstract classes handle Unicode character
streams
• The abstract classes Reader and Writer define several
key methods that the other stream classes implement
• Two of the most important methods are read( ) and
write( ), which read and write characters of data
• These methods are overridden by derived stream
classes.
Java IO Package and Streams

More Related Content

PDF
Java I/o streams
PPTX
PPTX
Java swing
PPTX
Access specifiers(modifiers) in java
PPTX
Inheritance in java
PPTX
Inheritance in java
PPT
Exception Handling in JAVA
PPT
Java-java virtual machine
Java I/o streams
Java swing
Access specifiers(modifiers) in java
Inheritance in java
Inheritance in java
Exception Handling in JAVA
Java-java virtual machine

What's hot (20)

PPT
Applet life cycle
PPTX
Control statements in java
PPTX
Static keyword ppt
PPTX
Exception handling
PPS
Jdbc architecture and driver types ppt
PDF
Strings in java
PPT
Abstract class
PDF
JavaScript - Chapter 12 - Document Object Model
PPTX
Event In JavaScript
PPT
Method overriding
PDF
Java threads
PPT
Servlet life cycle
PPT
Thread model in java
PPT
Java And Multithreading
PDF
Java Fundamentals
PPTX
Inheritance in oops
PPTX
Thread priority in java
PPTX
Inner classes in java
PPTX
Java Strings
PPTX
Exception Handling in Java
Applet life cycle
Control statements in java
Static keyword ppt
Exception handling
Jdbc architecture and driver types ppt
Strings in java
Abstract class
JavaScript - Chapter 12 - Document Object Model
Event In JavaScript
Method overriding
Java threads
Servlet life cycle
Thread model in java
Java And Multithreading
Java Fundamentals
Inheritance in oops
Thread priority in java
Inner classes in java
Java Strings
Exception Handling in Java
Ad

Viewers also liked (20)

PDF
Java Course 8: I/O, Files and Streams
PPTX
Java Input Output (java.io.*)
PPTX
Handling I/O in Java
PDF
PPT
Unit v
PPT
Jedi Slides Intro2 Chapter12 Advanced Io Streams
PDF
Java IO
PDF
I/O in java Part 1
PPTX
L21 io streams
PPT
Java API, Exceptions and IO
PPT
Various io stream classes .47
PPT
9. Input Output in java
PPS
Files & IO in Java
PDF
My History
ODP
IO In Java
PDF
Design Pattern From Java To Ruby
PPTX
Understanding java streams
PPTX
Java Multi Thead Programming
PPTX
Multi-threaded Programming in JAVA
PPT
Threads in Java
Java Course 8: I/O, Files and Streams
Java Input Output (java.io.*)
Handling I/O in Java
Unit v
Jedi Slides Intro2 Chapter12 Advanced Io Streams
Java IO
I/O in java Part 1
L21 io streams
Java API, Exceptions and IO
Various io stream classes .47
9. Input Output in java
Files & IO in Java
My History
IO In Java
Design Pattern From Java To Ruby
Understanding java streams
Java Multi Thead Programming
Multi-threaded Programming in JAVA
Threads in Java
Ad

Similar to Java IO Package and Streams (20)

PDF
input/ output in java
PDF
inputoutputstreams-140612032817-phpapp02.pdf
PPT
Input output streams
PDF
Unit 4 - Javadfjjjjjjjjjjjjjjjaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa IO.pdf
PPTX
Chapter 13_m5JAVANOTESAPPLETS,INPUT.pptx
PDF
CSE3146-ADV JAVA M2.pdf
PPTX
CHAPTER 5 mechanical engineeringasaaa.pptx
PDF
Advanced programming ch2
PPTX
IOStream.pptx
PDF
Javaiostream
PDF
javaiostream
PDF
Basic IO
PPT
Various io stream classes .47
PPTX
Chapter 6
PPTX
2018 12-kube con-ballerinacon
PPTX
Open System INterconnection -OSI/ISO layer
PPT
Java development development Files lectur6.ppt
PDF
CS-324-6-2.pdf
PPT
Md121 streams
DOC
Web Technology Web Technology Notes Streams Network Principles and SocketsUni...
input/ output in java
inputoutputstreams-140612032817-phpapp02.pdf
Input output streams
Unit 4 - Javadfjjjjjjjjjjjjjjjaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa IO.pdf
Chapter 13_m5JAVANOTESAPPLETS,INPUT.pptx
CSE3146-ADV JAVA M2.pdf
CHAPTER 5 mechanical engineeringasaaa.pptx
Advanced programming ch2
IOStream.pptx
Javaiostream
javaiostream
Basic IO
Various io stream classes .47
Chapter 6
2018 12-kube con-ballerinacon
Open System INterconnection -OSI/ISO layer
Java development development Files lectur6.ppt
CS-324-6-2.pdf
Md121 streams
Web Technology Web Technology Notes Streams Network Principles and SocketsUni...

More from babak danyal (20)

DOCX
applist
PPT
Easy Steps to implement UDP Server and Client Sockets
PPT
Swing and Graphical User Interface in Java
PPT
Tcp sockets
PPTX
block ciphers and the des
PPT
key distribution in network security
PPT
Lecture10 Signal and Systems
PPT
Lecture8 Signal and Systems
PPT
Lecture7 Signal and Systems
PPT
Lecture6 Signal and Systems
PPT
Lecture5 Signal and Systems
PPT
Lecture4 Signal and Systems
PPT
Lecture3 Signal and Systems
PPT
Lecture2 Signal and Systems
PPT
Lecture1 Intro To Signa
PPT
Lecture9 Signal and Systems
PPT
Lecture9
PPT
Cns 13f-lec03- Classical Encryption Techniques
PPT
Classical Encryption Techniques in Network Security
DOCX
Problems at independence
applist
Easy Steps to implement UDP Server and Client Sockets
Swing and Graphical User Interface in Java
Tcp sockets
block ciphers and the des
key distribution in network security
Lecture10 Signal and Systems
Lecture8 Signal and Systems
Lecture7 Signal and Systems
Lecture6 Signal and Systems
Lecture5 Signal and Systems
Lecture4 Signal and Systems
Lecture3 Signal and Systems
Lecture2 Signal and Systems
Lecture1 Intro To Signa
Lecture9 Signal and Systems
Lecture9
Cns 13f-lec03- Classical Encryption Techniques
Classical Encryption Techniques in Network Security
Problems at independence

Recently uploaded (20)

PPTX
Pharma ospi slides which help in ospi learning
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
PPH.pptx obstetrics and gynecology in nursing
PPTX
Cell Types and Its function , kingdom of life
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
RMMM.pdf make it easy to upload and study
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
GDM (1) (1).pptx small presentation for students
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
Pharma ospi slides which help in ospi learning
STATICS OF THE RIGID BODIES Hibbelers.pdf
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Anesthesia in Laparoscopic Surgery in India
Pharmacology of Heart Failure /Pharmacotherapy of CHF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPH.pptx obstetrics and gynecology in nursing
Cell Types and Its function , kingdom of life
human mycosis Human fungal infections are called human mycosis..pptx
O5-L3 Freight Transport Ops (International) V1.pdf
FourierSeries-QuestionsWithAnswers(Part-A).pdf
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
RMMM.pdf make it easy to upload and study
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
GDM (1) (1).pptx small presentation for students
Renaissance Architecture: A Journey from Faith to Humanism

Java IO Package and Streams

  • 2. Introduction • Most programs cannot accomplish their goals without accessing external data • Data is retrieved from an input source and results of a program are sent to an output destination • These sources or destinations are defined very broadly in Java, e.g. a network connection, memory buffer, or disk file • The java.io package supports Java’s basic I/O (input/output) system • Java provides strong, flexible support for I/O as it relates to files and networks • physically different, these devices are all handled by the same abstraction: the stream
  • 3. Streams • A stream is a logical entity that either produces or consumes information • A stream is linked to a physical device by the Java I/O system • All streams behave in the same manner, even if the actual physical devices they are linked to differ • an input stream can abstract many different kinds of input: from a disk file, a keyboard, or a network socket • Likewise, an output stream may refer to the console, a disk file, or a network connection
  • 4. Types of Streams • Java 2 defines two types of streams: byte and character • Byte streams provide a convenient means for handling input and output of bytes • Byte streams are used when reading or writing binary data • Character streams provide a convenient means for handling input and output of characters • They use Unicode and, therefore, can be internationalized.
  • 5. Byte Streams • Byte Streams are defined by using two class hierarchies • At the top are two abstract classes: InputStream and OutputStream • Each of these abstract classes has several concrete subclasses • These classes handle the differences between various devices, such as disk files, network connections, and even memory buffers
  • 6. Byte Streams (contd) • The abstract classes InputStream and OutputStream define several key methods that the other stream classes implement • Two of the most important are read( ) and write( ) which read and write bytes of data • Both methods are declared as abstract and are overridden by derived stream classes
  • 7. Character Streams • Character streams are defined by using two class hierarchies • At the top are two abstract classes, Reader and Writer • These abstract classes handle Unicode character streams • The abstract classes Reader and Writer define several key methods that the other stream classes implement • Two of the most important methods are read( ) and write( ), which read and write characters of data • These methods are overridden by derived stream classes.