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
Ministry of Higher Education
 
PDF
Chapter 2 : Inet Address & Data Stream
Ministry of Higher Education
 
PPTX
Socket programming or network programming
Mmanan91
 
PPTX
Socket programming in C#
Nang Luc Vu
 
PPT
Java Network Programming
backdoor
 
PDF
Socket programming
NemiRathore
 
PPTX
Java
kasthurimukila
 
PPTX
Java socket programming
Mohammed Abdalla Youssif
 
Chap 1 Network Theory & Java Overview
Ministry of Higher Education
 
Chapter 2 : Inet Address & Data Stream
Ministry of Higher Education
 
Socket programming or network programming
Mmanan91
 
Socket programming in C#
Nang Luc Vu
 
Java Network Programming
backdoor
 
Socket programming
NemiRathore
 
Java socket programming
Mohammed Abdalla Youssif
 

What's hot (20)

PDF
Java- Datagram Socket class & Datagram Packet class
Ruchi Maurya
 
PPTX
Advance Java-Network Programming
ashok hirpara
 
PPTX
Networking in python by Rj
Shree M.L.Kakadiya MCA mahila college, Amreli
 
PPTX
Whole c++ lectures ITM1 Th
Aram Mohammed
 
PPTX
Unit 2 : Internet Address
Chandan Gupta Bhagat
 
PPT
WIFI MODEM Part-22
Techvilla
 
PDF
Python network programming
Learnbay Datascience
 
PPTX
Socket programming
MdEmonRana
 
PPT
Socket Programming
CEC Landran
 
PPT
Java networking
Arati Gadgil
 
PDF
Network Programming Assignment Help
HelpWithAssignment.com
 
PPTX
Addressing in networking (IP,MAC,Port addressing)
Geethu Jose
 
PPTX
Socket Programming w/ C# - IK
Ilgın Kavaklıoğulları
 
PPTX
Java networking
ssuser3a47cb
 
PDF
IP Datagram Structure
Hitesh Mohapatra
 
PPTX
Internet protocol (ip)
junnubabu
 
DOC
socket programming
prashantzagade
 
PPTX
Session 6
Parthipan Parthi
 
PPTX
IPC SOCKET
Sanoj Kumar
 
PPT
Internet protocol
Online
 
Java- Datagram Socket class & Datagram Packet class
Ruchi Maurya
 
Advance Java-Network Programming
ashok hirpara
 
Whole c++ lectures ITM1 Th
Aram Mohammed
 
Unit 2 : Internet Address
Chandan Gupta Bhagat
 
WIFI MODEM Part-22
Techvilla
 
Python network programming
Learnbay Datascience
 
Socket programming
MdEmonRana
 
Socket Programming
CEC Landran
 
Java networking
Arati Gadgil
 
Network Programming Assignment Help
HelpWithAssignment.com
 
Addressing in networking (IP,MAC,Port addressing)
Geethu Jose
 
Socket Programming w/ C# - IK
Ilgın Kavaklıoğulları
 
Java networking
ssuser3a47cb
 
IP Datagram Structure
Hitesh Mohapatra
 
Internet protocol (ip)
junnubabu
 
socket programming
prashantzagade
 
Session 6
Parthipan Parthi
 
IPC SOCKET
Sanoj Kumar
 
Internet protocol
Online
 
Ad

Viewers also liked (12)

PDF
Detecting Anomalies in Streaming Data
Subutai Ahmad
 
PDF
Big Data and Stream Data Analysis at Politecnico di Milano
Marco Brambilla
 
PPTX
Data streaming algorithms
Sandeep Joshi
 
PPTX
[RakutenTechConf2013] [D-3_2] Counting Big Data by Streaming Algorithms
Rakuten Group, Inc.
 
PPTX
Streaming Algorithms
Joe Kelley
 
PPTX
Data Stream Outlier Detection Algorithm
Hamza Aslam
 
PDF
Stream processing using Apache Storm - Big Data Meetup Athens 2016
Adrianos Dadis
 
PPTX
Data Stream Algorithms in Storm and R
Radek Maciaszek
 
PDF
Discover.hdp2.2.storm and kafka.final
Hortonworks
 
PDF
Márton Balassi Streaming ML with Flink-
Flink Forward
 
PDF
Data Stream Analytics - Why they are important
Paris Carbone
 
PDF
Advanced data science algorithms applied to scalable stream processing by Dav...
Big Data Spain
 
Detecting Anomalies in Streaming Data
Subutai Ahmad
 
Big Data and Stream Data Analysis at Politecnico di Milano
Marco Brambilla
 
Data streaming algorithms
Sandeep Joshi
 
[RakutenTechConf2013] [D-3_2] Counting Big Data by Streaming Algorithms
Rakuten Group, Inc.
 
Streaming Algorithms
Joe Kelley
 
Data Stream Outlier Detection Algorithm
Hamza Aslam
 
Stream processing using Apache Storm - Big Data Meetup Athens 2016
Adrianos Dadis
 
Data Stream Algorithms in Storm and R
Radek Maciaszek
 
Discover.hdp2.2.storm and kafka.final
Hortonworks
 
Márton Balassi Streaming ML with Flink-
Flink Forward
 
Data Stream Analytics - Why they are important
Paris Carbone
 
Advanced data science algorithms applied to scalable stream processing by Dav...
Big Data Spain
 
Ad

Similar to Chapter 2.1 : Data Stream (20)

PDF
Advanced programming ch2
Gera Paulos
 
PDF
inputoutputstreams-140612032817-phpapp02.pdf
hemanth248901
 
PPT
Input output streams
Parthipan Parthi
 
PPTX
CHAPTER 5 mechanical engineeringasaaa.pptx
SadhilAggarwal
 
PDF
CSE3146-ADV JAVA M2.pdf
VithalReddy3
 
PPTX
L21 io streams
teach4uin
 
PPT
ch09.ppt
NiharikaDubey17
 
PPT
cis083_javaIOv gvhjvjkbkjbkjbjkbklbj.ppt
Vijay Bhaskar Thatty
 
PPTX
Reading and Writing Files
primeteacher32
 
PDF
input/ output in java
sharma230399
 
PPTX
Linux System Programming - Buffered I/O
YourHelper1
 
PPT
Md121 streams
Rakesh Madugula
 
PPTX
IOStream.pptx
HindAlmisbahi
 
PPTX
Stream In Java.pptx
ssuser9d7049
 
PDF
Java I/O
Jussi Pohjolainen
 
PDF
javaiostream
Arjun Shanka
 
PDF
Javaiostream
Tien Nguyen
 
PPTX
Chapter 13_m5JAVANOTESAPPLETS,INPUT.pptx
noonoboom
 
PPTX
Javaiostream
Manav Prasad
 
Advanced programming ch2
Gera Paulos
 
inputoutputstreams-140612032817-phpapp02.pdf
hemanth248901
 
Input output streams
Parthipan Parthi
 
CHAPTER 5 mechanical engineeringasaaa.pptx
SadhilAggarwal
 
CSE3146-ADV JAVA M2.pdf
VithalReddy3
 
L21 io streams
teach4uin
 
ch09.ppt
NiharikaDubey17
 
cis083_javaIOv gvhjvjkbkjbkjbjkbklbj.ppt
Vijay Bhaskar Thatty
 
Reading and Writing Files
primeteacher32
 
input/ output in java
sharma230399
 
Linux System Programming - Buffered I/O
YourHelper1
 
Md121 streams
Rakesh Madugula
 
IOStream.pptx
HindAlmisbahi
 
Stream In Java.pptx
ssuser9d7049
 
javaiostream
Arjun Shanka
 
Javaiostream
Tien Nguyen
 
Chapter 13_m5JAVANOTESAPPLETS,INPUT.pptx
noonoboom
 
Javaiostream
Manav Prasad
 

Recently uploaded (20)

PPTX
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
PPTX
Measures_of_location_-_Averages_and__percentiles_by_DR SURYA K.pptx
Surya Ganesh
 
PPTX
Artificial Intelligence in Gastroentrology: Advancements and Future Presprec...
AyanHossain
 
PPTX
Care of patients with elImination deviation.pptx
AneetaSharma15
 
PDF
BÀI TẬP TEST BỔ TRỢ THEO TỪNG CHỦ ĐỀ CỦA TỪNG UNIT KÈM BÀI TẬP NGHE - TIẾNG A...
Nguyen Thanh Tu Collection
 
PDF
Virat Kohli- the Pride of Indian cricket
kushpar147
 
PPTX
Sonnet 130_ My Mistress’ Eyes Are Nothing Like the Sun By William Shakespear...
DhatriParmar
 
PPTX
A Smarter Way to Think About Choosing a College
Cyndy McDonald
 
PPTX
PROTIEN ENERGY MALNUTRITION: NURSING MANAGEMENT.pptx
PRADEEP ABOTHU
 
PDF
Review of Related Literature & Studies.pdf
Thelma Villaflores
 
PPTX
CONCEPT OF CHILD CARE. pptx
AneetaSharma15
 
PDF
Health-The-Ultimate-Treasure (1).pdf/8th class science curiosity /samyans edu...
Sandeep Swamy
 
PPTX
Five Point Someone – Chetan Bhagat | Book Summary & Analysis by Bhupesh Kushwaha
Bhupesh Kushwaha
 
PPTX
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
PPTX
Basics and rules of probability with real-life uses
ravatkaran694
 
PPTX
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
Priyanshu Anand
 
PPTX
How to Apply for a Job From Odoo 18 Website
Celine George
 
DOCX
SAROCES Action-Plan FOR ARAL PROGRAM IN DEPED
Levenmartlacuna1
 
PDF
Antianginal agents, Definition, Classification, MOA.pdf
Prerana Jadhav
 
PPTX
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
Measures_of_location_-_Averages_and__percentiles_by_DR SURYA K.pptx
Surya Ganesh
 
Artificial Intelligence in Gastroentrology: Advancements and Future Presprec...
AyanHossain
 
Care of patients with elImination deviation.pptx
AneetaSharma15
 
BÀI TẬP TEST BỔ TRỢ THEO TỪNG CHỦ ĐỀ CỦA TỪNG UNIT KÈM BÀI TẬP NGHE - TIẾNG A...
Nguyen Thanh Tu Collection
 
Virat Kohli- the Pride of Indian cricket
kushpar147
 
Sonnet 130_ My Mistress’ Eyes Are Nothing Like the Sun By William Shakespear...
DhatriParmar
 
A Smarter Way to Think About Choosing a College
Cyndy McDonald
 
PROTIEN ENERGY MALNUTRITION: NURSING MANAGEMENT.pptx
PRADEEP ABOTHU
 
Review of Related Literature & Studies.pdf
Thelma Villaflores
 
CONCEPT OF CHILD CARE. pptx
AneetaSharma15
 
Health-The-Ultimate-Treasure (1).pdf/8th class science curiosity /samyans edu...
Sandeep Swamy
 
Five Point Someone – Chetan Bhagat | Book Summary & Analysis by Bhupesh Kushwaha
Bhupesh Kushwaha
 
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
Basics and rules of probability with real-life uses
ravatkaran694
 
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
Priyanshu Anand
 
How to Apply for a Job From Odoo 18 Website
Celine George
 
SAROCES Action-Plan FOR ARAL PROGRAM IN DEPED
Levenmartlacuna1
 
Antianginal agents, Definition, Classification, MOA.pdf
Prerana Jadhav
 
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 

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.