SlideShare a Scribd company logo
Data Stream
“Stream is a process to read a data from 1 resource or send
a data to another location.”
What is Stream
• All data in JAVA platform was read and write by Stream
• Stream is a process to read a data from 1 resource and
send a data to another location.
• Example :
– Read and write file at and to Harddisk
– Read and write text to console
– Read and write to network
• Stream has 2 type :
– Stream Byte (8bit): File for binary data
– Stream Character (16bit) : File for Unicode data
Character Stream
Byte Stream
Java.io Hierarchy
• Package java.io was develop to make easy for
user to do an various type for input or output
process such as Objects, Strings and Bytes.
• It also design in order to receive input and
output from various source such as keyboard,
network and disk.
I/O Stream
• To READ, a program will open STREAM at a resource
(file, memory, socket) and READ an information in
sequential.
• And to WRITE, a program will send an information to a
destination. It will open a STREAM and it will WRITE an
information in sequential
• hhhhhhhhhhhhh
Reader and Writer
• Use for READ and WRITE text data
• It more easy then InputStream and
OutputStream
• For fast performance, use a buffering facility,
Example : BufferedReader.
Reader
• To READ a text by paragraph, use below
technique :
– File f = new Fine (“C:OOPMyText.txt”);
– FileReader fr = mew FileReader(f);
– BufferedReader fin = new BufferedReader(fr);
• FileReader is a lane that provide to read a File.
• BufferedReader wrap a FileReader in order to
make input process using buffering technique.
Input DataStream
Input DataStream
Reader vs Writer
• Reader
– BufferedReader
– CharArrayReader
– FilterReader
– InputStreamReader
– FileReader
– PipedReader
– StringReader
• Writer
– BufferedWriter
– CharArrayWriter
– FilterWriter
– OutputStreamWriter
– FileWriter
– PipedWriter
– StringWriter
– PrintWriter
Reader
• After BufferedReader formed, String will be
taken with a readLine() method that use to
return a String value.
• To display a data it will use print() or println().
Writer
• Use to WRITE a text line by line use following
technique :
– File f = new File (“C:OOPMyText.txt”);
– FileWriter fw = new FileWriter(f);
– PrintWriter fin = new PrintWriter(fw);
• A file will be process to be FileWriter that is
needed for output.
• PrintWriter is needed in order to make program
can use a print() and println() method.
Output Stream
Output DataStream
Stream Byte
• Actually stream byte divide by 2 class :
InputStream and OutputStream
• InputStream and OutStream is a higher level
in java.io package.
Stream Byte
• InputStream and OutStream is a class for
stream I/O that use to READ and WRITE a data
from and to file.
• For READ a file, we use : FileInputStream
• For WRITE a file, we use : FileOutputStream
InputStream vs OutputStream
How to use a byte stream?
INPUT STREAM OUTPUT STREAM
Create object that oriented with source
data.
Eg : FileInputStream
Create object that oriented with
destination data.
Eg : BufferedWriter
Read information from stream by using
object method.
Eg : read()
Write an information to stream by using
object method.
Eg : write()
When complete, close method will be
call.
When complete, closure method will be
call.

More Related Content

PDF
Chap 1 Network Theory & Java Overview
PDF
Chapter 2 : Inet Address & Data Stream
PPTX
Socket programming or network programming
PPTX
Socket programming in C#
PPT
Java Network Programming
PDF
Socket programming
PPTX
PPTX
Java socket programming
Chap 1 Network Theory & Java Overview
Chapter 2 : Inet Address & Data Stream
Socket programming or network programming
Socket programming in C#
Java Network Programming
Socket programming
Java socket programming

What's hot (20)

PDF
Java- Datagram Socket class & Datagram Packet class
PPTX
Advance Java-Network Programming
PPTX
PPTX
Whole c++ lectures ITM1 Th
PPTX
Unit 2 : Internet Address
PPT
WIFI MODEM Part-22
PDF
Python network programming
PPTX
Socket programming
PPT
Socket Programming
PPT
Java networking
PDF
Network Programming Assignment Help
PPTX
Addressing in networking (IP,MAC,Port addressing)
PPTX
Socket Programming w/ C# - IK
PPTX
Java networking
PDF
IP Datagram Structure
PPTX
Internet protocol (ip)
DOC
socket programming
PPTX
Session 6
PPTX
IPC SOCKET
PPT
Internet protocol
Java- Datagram Socket class & Datagram Packet class
Advance Java-Network Programming
Whole c++ lectures ITM1 Th
Unit 2 : Internet Address
WIFI MODEM Part-22
Python network programming
Socket programming
Socket Programming
Java networking
Network Programming Assignment Help
Addressing in networking (IP,MAC,Port addressing)
Socket Programming w/ C# - IK
Java networking
IP Datagram Structure
Internet protocol (ip)
socket programming
Session 6
IPC SOCKET
Internet protocol
Ad

Viewers also liked (12)

PDF
Detecting Anomalies in Streaming Data
PDF
Big Data and Stream Data Analysis at Politecnico di Milano
PPTX
Data streaming algorithms
PPTX
[RakutenTechConf2013] [D-3_2] Counting Big Data by Streaming Algorithms
PPTX
Streaming Algorithms
PPTX
Data Stream Outlier Detection Algorithm
PDF
Stream processing using Apache Storm - Big Data Meetup Athens 2016
PPTX
Data Stream Algorithms in Storm and R
PDF
Discover.hdp2.2.storm and kafka.final
PDF
Márton Balassi Streaming ML with Flink-
PDF
Data Stream Analytics - Why they are important
PDF
Advanced data science algorithms applied to scalable stream processing by Dav...
Detecting Anomalies in Streaming Data
Big Data and Stream Data Analysis at Politecnico di Milano
Data streaming algorithms
[RakutenTechConf2013] [D-3_2] Counting Big Data by Streaming Algorithms
Streaming Algorithms
Data Stream Outlier Detection Algorithm
Stream processing using Apache Storm - Big Data Meetup Athens 2016
Data Stream Algorithms in Storm and R
Discover.hdp2.2.storm and kafka.final
Márton Balassi Streaming ML with Flink-
Data Stream Analytics - Why they are important
Advanced data science algorithms applied to scalable stream processing by Dav...
Ad

Similar to Chapter 2.1 : Data Stream (20)

PPTX
PDF
Java IO Stream, the introduction to Streams
PPTX
L21 io streams
PDF
11_Str11_Streams.11_Streams.11_Streams.11_Streams.11_Streams.11_Streams.eams.pdf
PPTX
Input output files in java
PPTX
Stream In Java.pptx
PPTX
IOStream.pptx
PDF
IOstreams hgjhsgfdjyggckhgckhjxfhbuvobunciu
PPTX
Javaiostream
PPTX
IO Programming.pptx all informatiyon ppt
PPT
Javaio
PPT
Javaio
PPTX
Java I/O
PPT
Itp 120 Chapt 19 2009 Binary Input & Output
PPT
Using Input Output
PPTX
Java Input Output (java.io.*)
PDF
Monhocvecaujahetvagiuplaptunhhayhonha.pdf
PPTX
Files and streams In Java
PDF
Java Day-6
PPT
Java development development Files lectur6.ppt
Java IO Stream, the introduction to Streams
L21 io streams
11_Str11_Streams.11_Streams.11_Streams.11_Streams.11_Streams.11_Streams.eams.pdf
Input output files in java
Stream In Java.pptx
IOStream.pptx
IOstreams hgjhsgfdjyggckhgckhjxfhbuvobunciu
Javaiostream
IO Programming.pptx all informatiyon ppt
Javaio
Javaio
Java I/O
Itp 120 Chapt 19 2009 Binary Input & Output
Using Input Output
Java Input Output (java.io.*)
Monhocvecaujahetvagiuplaptunhhayhonha.pdf
Files and streams In Java
Java Day-6
Java development development Files lectur6.ppt

Recently uploaded (20)

PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
01-Introduction-to-Information-Management.pdf
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
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
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Cell Types and Its function , kingdom of life
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
Lesson notes of climatology university.
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
Pre independence Education in Inndia.pdf
PDF
Classroom Observation Tools for Teachers
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
VCE English Exam - Section C Student Revision Booklet
human mycosis Human fungal infections are called human mycosis..pptx
01-Introduction-to-Information-Management.pdf
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
O5-L3 Freight Transport Ops (International) V1.pdf
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Final Presentation General Medicine 03-08-2024.pptx
Cell Types and Its function , kingdom of life
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Lesson notes of climatology university.
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Microbial disease of the cardiovascular and lymphatic systems
Module 4: Burden of Disease Tutorial Slides S2 2025
Pre independence Education in Inndia.pdf
Classroom Observation Tools for Teachers
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
VCE English Exam - Section C Student Revision Booklet

Chapter 2.1 : Data Stream

  • 1. Data Stream “Stream is a process to read a data from 1 resource or send a data to another location.”
  • 2. What is Stream • All data in JAVA platform was read and write by Stream • Stream is a process to read a data from 1 resource and send a data to another location. • Example : – Read and write file at and to Harddisk – Read and write text to console – Read and write to network • Stream has 2 type : – Stream Byte (8bit): File for binary data – Stream Character (16bit) : File for Unicode data
  • 5. Java.io Hierarchy • Package java.io was develop to make easy for user to do an various type for input or output process such as Objects, Strings and Bytes. • It also design in order to receive input and output from various source such as keyboard, network and disk.
  • 6. I/O Stream • To READ, a program will open STREAM at a resource (file, memory, socket) and READ an information in sequential. • And to WRITE, a program will send an information to a destination. It will open a STREAM and it will WRITE an information in sequential • hhhhhhhhhhhhh
  • 7. Reader and Writer • Use for READ and WRITE text data • It more easy then InputStream and OutputStream • For fast performance, use a buffering facility, Example : BufferedReader.
  • 8. Reader • To READ a text by paragraph, use below technique : – File f = new Fine (“C:OOPMyText.txt”); – FileReader fr = mew FileReader(f); – BufferedReader fin = new BufferedReader(fr); • FileReader is a lane that provide to read a File. • BufferedReader wrap a FileReader in order to make input process using buffering technique.
  • 11. Reader vs Writer • Reader – BufferedReader – CharArrayReader – FilterReader – InputStreamReader – FileReader – PipedReader – StringReader • Writer – BufferedWriter – CharArrayWriter – FilterWriter – OutputStreamWriter – FileWriter – PipedWriter – StringWriter – PrintWriter
  • 12. Reader • After BufferedReader formed, String will be taken with a readLine() method that use to return a String value. • To display a data it will use print() or println().
  • 13. Writer • Use to WRITE a text line by line use following technique : – File f = new File (“C:OOPMyText.txt”); – FileWriter fw = new FileWriter(f); – PrintWriter fin = new PrintWriter(fw); • A file will be process to be FileWriter that is needed for output. • PrintWriter is needed in order to make program can use a print() and println() method.
  • 16. Stream Byte • Actually stream byte divide by 2 class : InputStream and OutputStream • InputStream and OutStream is a higher level in java.io package.
  • 17. Stream Byte • InputStream and OutStream is a class for stream I/O that use to READ and WRITE a data from and to file. • For READ a file, we use : FileInputStream • For WRITE a file, we use : FileOutputStream
  • 19. How to use a byte stream? INPUT STREAM OUTPUT STREAM Create object that oriented with source data. Eg : FileInputStream Create object that oriented with destination data. Eg : BufferedWriter Read information from stream by using object method. Eg : read() Write an information to stream by using object method. Eg : write() When complete, close method will be call. When complete, closure method will be call.