SlideShare ist ein Scribd-Unternehmen logo
1 von 105
JAVA  I/O STREAMS NETWORK PROGRAMMING
PART 1 – INPUT/OUTPUT STREAMS ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Stream concepts ,[object Object],[object Object],Program File Memory Network Program information
Stream ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Input & Output Stream Hình 1:  Chương trình xử lý dữ liệu từ 1 input stream Hình 2:   Chương trình ghi dữ liệu ra output stream
Trình tự đọc/ ghi dòng open  input stream while  (more information){ read  information process  information } close  input stream open  output stream while  (more information){ get information from ... write  information } close  output stream Đọc thông tin  từ input stream Ghi thông tin  vào output stream
Các loại stream trong package java.io ,[object Object],[object Object],[object Object]
Nhóm input/output stream ,[object Object],[object Object],[object Object],[object Object],[object Object]
Nhóm input stream
Nhóm output stream
Nhóm reader/writer ,[object Object]
Nhóm Writer
Các loại các stream (tt) ,[object Object],[object Object],[object Object]
Tổng quát về các Streams StringReader  để đọc các ký tự từ một  String  trong bộ nhớ.  StringWriter  để ghi vào  String . StringBufferInputStream  tương tự như  StringReader . Sự khác biệt chỉ là  StringBufferInputStream  đọc các bytes từ một đối tượng  StringBuffer StringReader StringWriter StringBuffer- InputStream Đọc/ghi từ/vào bộ nhớ. Tạo stream từ một mảng, tiếp theo dùng các phương thức đọc/ghi để đọc/ghi từ/vào mảng. Tác vụ đọc sẽ lấy dữ liệu từ mảng Tác vụ ghi sẽ ghi ra mảng CharArrayReader CharArrayWriter ByteArrayInput- Stream ByteArrayOutput-Stream Memory Mô tả khái quát Streams I/O
Tổng quát về các Streams Nối nhiều input streams thành một input stream. SequenceInput- Stream ( concatenation ) Nối Được gọi là các file streams. File streams dùng để đọc/ghi từ/vào file trên file system. FileReader FileWriter FileInputStream FileOutputStream File Hiện thực các thành phần input và output của một pipe. Pipes được dùng như một kênh truyền, nối output của một thread vào input của một thread khác. PipedReader PipedWriter PipedInputStream PipedOutputStream Pipe
Tổng quát về các Streams Theo dõi số hàng trong khi đọc LineNumberReader  LineNumberInput- Stream Counting Thuận tiện khi cần đọc/ghi các kiểu dữ liệu cơ bản ( primitive data types ) như  int ,  double , ...  DataInputStream DataOutputStream Chuyển đổi dạng dữ liệu  ( Data Conver-sion ) Dùng khi cần lưu trữ, khôi phục, hoặc truyền toàn bộ đối tượng. ObjectInputStream ObjectOutputStream Object Serial- ization
Tổng quát về các Streams Các lớp abstract này định nghĩa các giao tiếp cho các filter streams lọc dữ liệu trong khi đọc/ghi. FilterReader FilterWriter FilterInputStream FilterOutputStream Lọc dữ liệu ( Filtering ) Đệm dữ liệu trong các thao tác đọc/ghi. Đệm dữ liệu cải thiện tốc độ đọc ghi vì giảm số lần truy xuất thiết bị. BufferedReader BufferedWriter bufferedInput-Stream BufferedOutput-Stream Đệm  ( Buffer-ing ) Rất thuận tiện khi cần kết xuất, dễ đọc với người.  System.out  là một đối tượng thuộc lớp  PrintStream . PrintWriter PrintStream Printing
Tổng quát về các Streams Cặp reader/writer này là cầu nối giữa các byte streams và character streams. Một  InputStreamReader  đọc các bytes từ một  InputStream  và chuyển các bytes đó thành các ký tự. Một  OutputStreamWriter  chuyển các ký tự sang các bytes, và ghi các bytes đó vào một  OutputStream . Quá trình chuyển đổi sẽ sử dụng bộ mã mặc định nếu không được chỉ định rõ. Gọi  System.getProperty ("file.encoding")  để lấy về tên bộ mã mặc định. InputStreamReader OutputStreamWriter Chuyển đổi  byte    ký tự  ( Converting between Bytes and Characters )
Các lớp IO  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
InputSream ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The java.io.InputStream Class ,[object Object],[object Object],[object Object],[object Object],[object Object]
The java.io.InputStream Class ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The java.io.InputStream Class ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The java.io.File Class ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The java.io.File Class ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The java.io.File Class ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The java.io.File Class ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The java.io.File Class ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The java.io.File Class ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Exercise ,[object Object],[object Object],[object Object]
The java.io.FileInputStream Class ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The java.io.FileInputStream Class ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The java.io.FileInputStream Class ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
FileInputStream Demo ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
FileInputStreamDemo ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Ouput Streams ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The java.io.OutputStream Class ,[object Object],[object Object]
The java.io.OutputStream Class ,[object Object],[object Object],[object Object]
Java.io.FileOutputStream  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Java.io.FileOutputStream ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
FileOutputStream Demo (FileCopy) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
FileOutputStream Demo (FileCopy) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
FileOutputStream Demo (FileCopy) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Filter Streams ,[object Object],[object Object],[object Object]
Filter Streams ,[object Object],[object Object],[object Object],[object Object],[object Object]
Filter Input Streams ,[object Object],[object Object],[object Object],[object Object]
BufferedInputStream ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
FileCopy using BufferedInputStream ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
A Speed of new FileCopy  ,[object Object],[object Object],[object Object],[object Object]
DataInputStream Class ,[object Object],[object Object]
DataInputStream Class ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
DataInputStream Class ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
PrintStream Class ,[object Object],[object Object],[object Object]
PrintStream Class ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Random Access File Stream ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Random Access File Stream
Java.io.RandomAccessFile  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Java.io.RandomAccessFile ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Java.io.RandomAccessFile ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Java.io.RandomAccessFile ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Java.io.RandomAccessFile ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Java.io.RandomAccessFile ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
New I/O ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
java.nio.ByteBuffer  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
java.nio.ByteBuffer ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
java.nio.ByteBuffer ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
java.nio.ByteBuffer ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
java.nio.Buffer ,[object Object],[object Object],[object Object],[object Object],[object Object]
java.nio.Buffer ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
java.nio.Buffer ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
java.nio.Buffer ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
java.nio.channels.FileChannel  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
java.nio.channels.FileChannel  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
java.nio.channels.FileChannel  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
java.nio.channels.FileChannel  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
java.nio.channels.FileChannel  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
java.nio.channels.FileChannel  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
CRC without Memory-Mapped file ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
CRC with Memory-Mapped file ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Readers and Writers ,[object Object],[object Object]
Writers ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Writers ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
java.io.FileWriter  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Text Stream ,[object Object],[object Object],[object Object],[object Object],[object Object]
 
BufferedReader
BufferedWriter
java.io.OutputStreamWriter  ,[object Object],[object Object],[object Object]
java.io.OutputStreamWriter ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
java.io.OutputStreamWriter ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
OutputStreamWriter demo ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
java.io.InputStreamReader  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
java.io.InputStreamReader  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Charset Translation  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Complete example ,[object Object]
Object Streams ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Storing Objects of Variable Type  ,[object Object],[object Object],[object Object],[object Object],[object Object]
Reading Objects back ,[object Object],[object Object],[object Object],[object Object],[object Object]
Serializable interface ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Student List using Object Streams ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Student List using Object Streams   ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
java.io.ObjectOutputStream   ,[object Object],[object Object]
java.io.ObjectInputStream  ,[object Object],[object Object]
InputStream Summary
OutputStream Summary

Weitere ähnliche Inhalte

Was ist angesagt?

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 StreamsAnton Keks
 
IO In Java
IO In JavaIO In Java
IO In Javaparag
 
Java Input Output (java.io.*)
Java Input Output (java.io.*)Java Input Output (java.io.*)
Java Input Output (java.io.*)Om Ganesh
 
L21 io streams
L21 io streamsL21 io streams
L21 io streamsteach4uin
 
Java - File Input Output Concepts
Java - File Input Output ConceptsJava - File Input Output Concepts
Java - File Input Output ConceptsVicter Paul
 
Using Input Output
Using Input OutputUsing Input Output
Using Input Outputraksharao
 
Files & IO in Java
Files & IO in JavaFiles & IO in Java
Files & IO in JavaCIB Egypt
 
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 javaJayasankarPR2
 
Byte stream classes.49
Byte stream classes.49Byte stream classes.49
Byte stream classes.49myrajendra
 
Various io stream classes .47
Various io stream classes .47Various io stream classes .47
Various io stream classes .47myrajendra
 
Java IO Package and Streams
Java IO Package and StreamsJava IO Package and Streams
Java IO Package and Streamsbabak danyal
 

Was ist angesagt? (20)

Java IO
Java IOJava IO
Java IO
 
Oodp mod4
Oodp mod4Oodp mod4
Oodp mod4
 
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
 
IO In Java
IO In JavaIO In Java
IO In Java
 
Java Input Output (java.io.*)
Java Input Output (java.io.*)Java Input Output (java.io.*)
Java Input Output (java.io.*)
 
Handling I/O in Java
Handling I/O in JavaHandling I/O in Java
Handling I/O in Java
 
Java
JavaJava
Java
 
L21 io streams
L21 io streamsL21 io streams
L21 io streams
 
Javaiostream
JavaiostreamJavaiostream
Javaiostream
 
Java - File Input Output Concepts
Java - File Input Output ConceptsJava - File Input Output Concepts
Java - File Input Output Concepts
 
Java I/o streams
Java I/o streamsJava I/o streams
Java I/o streams
 
Using Input Output
Using Input OutputUsing Input Output
Using Input Output
 
Files & IO in Java
Files & IO in JavaFiles & IO in Java
Files & IO in Java
 
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
 
Byte stream classes.49
Byte stream classes.49Byte stream classes.49
Byte stream classes.49
 
Files in java
Files in javaFiles in java
Files in java
 
Various io stream classes .47
Various io stream classes .47Various io stream classes .47
Various io stream classes .47
 
32.java input-output
32.java input-output32.java input-output
32.java input-output
 
Java IO Package and Streams
Java IO Package and StreamsJava IO Package and Streams
Java IO Package and Streams
 
Java I/O
Java I/OJava I/O
Java I/O
 

Andere mochten auch

Ruloans - Loan Comparison Website
Ruloans - Loan Comparison WebsiteRuloans - Loan Comparison Website
Ruloans - Loan Comparison WebsiteRuLoans
 
Unlikely Events
Unlikely EventsUnlikely Events
Unlikely Eventsim_shubner
 
Hema rapidskillz certificate
Hema rapidskillz certificateHema rapidskillz certificate
Hema rapidskillz certificateHema Shekar
 
Recent IT Developments - 3D Printing
Recent IT Developments - 3D PrintingRecent IT Developments - 3D Printing
Recent IT Developments - 3D PrintingG-Swift
 
IU9 Summer Institue 2009
IU9 Summer Institue 2009IU9 Summer Institue 2009
IU9 Summer Institue 2009csmurphy575
 
Doprinos vjere u zaštiti prirode
Doprinos vjere u zaštiti prirodeDoprinos vjere u zaštiti prirode
Doprinos vjere u zaštiti prirodeIslamska misao
 
The Wayward Winner (Part 2) | Is Success Resources Scam
The Wayward Winner (Part 2) | Is Success Resources ScamThe Wayward Winner (Part 2) | Is Success Resources Scam
The Wayward Winner (Part 2) | Is Success Resources Scamsuccessresources1
 
Producción de algodón, la experiencia de Helvetas en África, Asia Central y u...
Producción de algodón, la experiencia de Helvetas en África, Asia Central y u...Producción de algodón, la experiencia de Helvetas en África, Asia Central y u...
Producción de algodón, la experiencia de Helvetas en África, Asia Central y u...Maximiliano Valencia
 
Mass communication thoery
Mass communication thoeryMass communication thoery
Mass communication thoeryRana Saddam
 
The Magic Of Making Up System
The Magic Of Making Up SystemThe Magic Of Making Up System
The Magic Of Making Up Systemcooneyxrunn9111
 
El mejor-mapa-de-la-2da.-guerra-mundial
El mejor-mapa-de-la-2da.-guerra-mundialEl mejor-mapa-de-la-2da.-guerra-mundial
El mejor-mapa-de-la-2da.-guerra-mundialaviber
 

Andere mochten auch (18)

Coleoptere
ColeoptereColeoptere
Coleoptere
 
kaushik bera
kaushik berakaushik bera
kaushik bera
 
Ruloans - Loan Comparison Website
Ruloans - Loan Comparison WebsiteRuloans - Loan Comparison Website
Ruloans - Loan Comparison Website
 
Lo1 task 2
Lo1 task 2Lo1 task 2
Lo1 task 2
 
Unlikely Events
Unlikely EventsUnlikely Events
Unlikely Events
 
Galicia
GaliciaGalicia
Galicia
 
Hema rapidskillz certificate
Hema rapidskillz certificateHema rapidskillz certificate
Hema rapidskillz certificate
 
Advert analysis 3
Advert analysis 3Advert analysis 3
Advert analysis 3
 
54581 el8 el8000_m3_ycah
54581 el8 el8000_m3_ycah54581 el8 el8000_m3_ycah
54581 el8 el8000_m3_ycah
 
Recent IT Developments - 3D Printing
Recent IT Developments - 3D PrintingRecent IT Developments - 3D Printing
Recent IT Developments - 3D Printing
 
IU9 Summer Institue 2009
IU9 Summer Institue 2009IU9 Summer Institue 2009
IU9 Summer Institue 2009
 
Doprinos vjere u zaštiti prirode
Doprinos vjere u zaštiti prirodeDoprinos vjere u zaštiti prirode
Doprinos vjere u zaštiti prirode
 
The Wayward Winner (Part 2) | Is Success Resources Scam
The Wayward Winner (Part 2) | Is Success Resources ScamThe Wayward Winner (Part 2) | Is Success Resources Scam
The Wayward Winner (Part 2) | Is Success Resources Scam
 
Unit 9 evaluation
Unit 9 evaluationUnit 9 evaluation
Unit 9 evaluation
 
Producción de algodón, la experiencia de Helvetas en África, Asia Central y u...
Producción de algodón, la experiencia de Helvetas en África, Asia Central y u...Producción de algodón, la experiencia de Helvetas en África, Asia Central y u...
Producción de algodón, la experiencia de Helvetas en África, Asia Central y u...
 
Mass communication thoery
Mass communication thoeryMass communication thoery
Mass communication thoery
 
The Magic Of Making Up System
The Magic Of Making Up SystemThe Magic Of Making Up System
The Magic Of Making Up System
 
El mejor-mapa-de-la-2da.-guerra-mundial
El mejor-mapa-de-la-2da.-guerra-mundialEl mejor-mapa-de-la-2da.-guerra-mundial
El mejor-mapa-de-la-2da.-guerra-mundial
 

Ähnlich wie Io Streams

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 & Outputphanleson
 
File Input and output.pptx
File Input  and output.pptxFile Input  and output.pptx
File Input and output.pptxcherryreddygannu
 
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 NotesSakkaravarthiS1
 
Stream In Java.pptx
Stream In Java.pptxStream In Java.pptx
Stream In Java.pptxssuser9d7049
 
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.pptxRathanMB
 
Input/Output Exploring java.io
Input/Output Exploring java.ioInput/Output Exploring java.io
Input/Output Exploring java.ioNilaNila16
 
Stream Based Input Output
Stream Based Input OutputStream Based Input Output
Stream Based Input OutputBharat17485
 
What is java input and output stream?
What is java input and output stream?What is java input and output stream?
What is java input and output stream?kanchanmahajan23
 
What is java input and output stream?
What is java input and output stream?What is java input and output stream?
What is java input and output stream?kanchanmahajan23
 
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 StreamsDon Bosco BSIT
 
Java - Processing input and output
Java - Processing input and outputJava - Processing input and output
Java - Processing input and outputRiccardo Cardin
 
Java program file I/O
Java program file I/OJava program file I/O
Java program file I/ONem Sothea
 
H U F F M A N Algorithm Class
H U F F M A N Algorithm ClassH U F F M A N Algorithm Class
H U F F M A N Algorithm ClassJade Danial
 

Ähnlich wie Io Streams (20)

Unit IV Notes.docx
Unit IV Notes.docxUnit IV Notes.docx
Unit IV Notes.docx
 
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
 
File Input and output.pptx
File Input  and output.pptxFile Input  and output.pptx
File Input and output.pptx
 
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
 
Stream In Java.pptx
Stream In Java.pptxStream In Java.pptx
Stream In Java.pptx
 
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
 
I/O Streams
I/O StreamsI/O Streams
I/O Streams
 
Input/Output Exploring java.io
Input/Output Exploring java.ioInput/Output Exploring java.io
Input/Output Exploring java.io
 
Java Day-6
Java Day-6Java Day-6
Java Day-6
 
Stream Based Input Output
Stream Based Input OutputStream Based Input Output
Stream Based Input Output
 
What is java input and output stream?
What is java input and output stream?What is java input and output stream?
What is java input and output stream?
 
What is java input and output stream?
What is java input and output stream?What is java input and output stream?
What is java input and output stream?
 
Md121 streams
Md121 streamsMd121 streams
Md121 streams
 
IOStream.pptx
IOStream.pptxIOStream.pptx
IOStream.pptx
 
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
 
Java - Processing input and output
Java - Processing input and outputJava - Processing input and output
Java - Processing input and output
 
Stream
StreamStream
Stream
 
JAVA
JAVAJAVA
JAVA
 
Java program file I/O
Java program file I/OJava program file I/O
Java program file I/O
 
H U F F M A N Algorithm Class
H U F F M A N Algorithm ClassH U F F M A N Algorithm Class
H U F F M A N Algorithm Class
 

Mehr von phanleson

Learning spark ch01 - Introduction to Data Analysis with Spark
Learning spark ch01 - Introduction to Data Analysis with SparkLearning spark ch01 - Introduction to Data Analysis with Spark
Learning spark ch01 - Introduction to Data Analysis with Sparkphanleson
 
Firewall - Network Defense in Depth Firewalls
Firewall - Network Defense in Depth FirewallsFirewall - Network Defense in Depth Firewalls
Firewall - Network Defense in Depth Firewallsphanleson
 
Mobile Security - Wireless hacking
Mobile Security - Wireless hackingMobile Security - Wireless hacking
Mobile Security - Wireless hackingphanleson
 
Authentication in wireless - Security in Wireless Protocols
Authentication in wireless - Security in Wireless ProtocolsAuthentication in wireless - Security in Wireless Protocols
Authentication in wireless - Security in Wireless Protocolsphanleson
 
E-Commerce Security - Application attacks - Server Attacks
E-Commerce Security - Application attacks - Server AttacksE-Commerce Security - Application attacks - Server Attacks
E-Commerce Security - Application attacks - Server Attacksphanleson
 
Hacking web applications
Hacking web applicationsHacking web applications
Hacking web applicationsphanleson
 
HBase In Action - Chapter 04: HBase table design
HBase In Action - Chapter 04: HBase table designHBase In Action - Chapter 04: HBase table design
HBase In Action - Chapter 04: HBase table designphanleson
 
HBase In Action - Chapter 10 - Operations
HBase In Action - Chapter 10 - OperationsHBase In Action - Chapter 10 - Operations
HBase In Action - Chapter 10 - Operationsphanleson
 
Hbase in action - Chapter 09: Deploying HBase
Hbase in action - Chapter 09: Deploying HBaseHbase in action - Chapter 09: Deploying HBase
Hbase in action - Chapter 09: Deploying HBasephanleson
 
Learning spark ch11 - Machine Learning with MLlib
Learning spark ch11 - Machine Learning with MLlibLearning spark ch11 - Machine Learning with MLlib
Learning spark ch11 - Machine Learning with MLlibphanleson
 
Learning spark ch10 - Spark Streaming
Learning spark ch10 - Spark StreamingLearning spark ch10 - Spark Streaming
Learning spark ch10 - Spark Streamingphanleson
 
Learning spark ch09 - Spark SQL
Learning spark ch09 - Spark SQLLearning spark ch09 - Spark SQL
Learning spark ch09 - Spark SQLphanleson
 
Learning spark ch07 - Running on a Cluster
Learning spark ch07 - Running on a ClusterLearning spark ch07 - Running on a Cluster
Learning spark ch07 - Running on a Clusterphanleson
 
Learning spark ch06 - Advanced Spark Programming
Learning spark ch06 - Advanced Spark ProgrammingLearning spark ch06 - Advanced Spark Programming
Learning spark ch06 - Advanced Spark Programmingphanleson
 
Learning spark ch05 - Loading and Saving Your Data
Learning spark ch05 - Loading and Saving Your DataLearning spark ch05 - Loading and Saving Your Data
Learning spark ch05 - Loading and Saving Your Dataphanleson
 
Learning spark ch04 - Working with Key/Value Pairs
Learning spark ch04 - Working with Key/Value PairsLearning spark ch04 - Working with Key/Value Pairs
Learning spark ch04 - Working with Key/Value Pairsphanleson
 
Learning spark ch01 - Introduction to Data Analysis with Spark
Learning spark ch01 - Introduction to Data Analysis with SparkLearning spark ch01 - Introduction to Data Analysis with Spark
Learning spark ch01 - Introduction to Data Analysis with Sparkphanleson
 
Hướng Dẫn Đăng Ký LibertaGia - A guide and introduciton about Libertagia
Hướng Dẫn Đăng Ký LibertaGia - A guide and introduciton about LibertagiaHướng Dẫn Đăng Ký LibertaGia - A guide and introduciton about Libertagia
Hướng Dẫn Đăng Ký LibertaGia - A guide and introduciton about Libertagiaphanleson
 
Lecture 1 - Getting to know XML
Lecture 1 - Getting to know XMLLecture 1 - Getting to know XML
Lecture 1 - Getting to know XMLphanleson
 
Lecture 4 - Adding XTHML for the Web
Lecture  4 - Adding XTHML for the WebLecture  4 - Adding XTHML for the Web
Lecture 4 - Adding XTHML for the Webphanleson
 

Mehr von phanleson (20)

Learning spark ch01 - Introduction to Data Analysis with Spark
Learning spark ch01 - Introduction to Data Analysis with SparkLearning spark ch01 - Introduction to Data Analysis with Spark
Learning spark ch01 - Introduction to Data Analysis with Spark
 
Firewall - Network Defense in Depth Firewalls
Firewall - Network Defense in Depth FirewallsFirewall - Network Defense in Depth Firewalls
Firewall - Network Defense in Depth Firewalls
 
Mobile Security - Wireless hacking
Mobile Security - Wireless hackingMobile Security - Wireless hacking
Mobile Security - Wireless hacking
 
Authentication in wireless - Security in Wireless Protocols
Authentication in wireless - Security in Wireless ProtocolsAuthentication in wireless - Security in Wireless Protocols
Authentication in wireless - Security in Wireless Protocols
 
E-Commerce Security - Application attacks - Server Attacks
E-Commerce Security - Application attacks - Server AttacksE-Commerce Security - Application attacks - Server Attacks
E-Commerce Security - Application attacks - Server Attacks
 
Hacking web applications
Hacking web applicationsHacking web applications
Hacking web applications
 
HBase In Action - Chapter 04: HBase table design
HBase In Action - Chapter 04: HBase table designHBase In Action - Chapter 04: HBase table design
HBase In Action - Chapter 04: HBase table design
 
HBase In Action - Chapter 10 - Operations
HBase In Action - Chapter 10 - OperationsHBase In Action - Chapter 10 - Operations
HBase In Action - Chapter 10 - Operations
 
Hbase in action - Chapter 09: Deploying HBase
Hbase in action - Chapter 09: Deploying HBaseHbase in action - Chapter 09: Deploying HBase
Hbase in action - Chapter 09: Deploying HBase
 
Learning spark ch11 - Machine Learning with MLlib
Learning spark ch11 - Machine Learning with MLlibLearning spark ch11 - Machine Learning with MLlib
Learning spark ch11 - Machine Learning with MLlib
 
Learning spark ch10 - Spark Streaming
Learning spark ch10 - Spark StreamingLearning spark ch10 - Spark Streaming
Learning spark ch10 - Spark Streaming
 
Learning spark ch09 - Spark SQL
Learning spark ch09 - Spark SQLLearning spark ch09 - Spark SQL
Learning spark ch09 - Spark SQL
 
Learning spark ch07 - Running on a Cluster
Learning spark ch07 - Running on a ClusterLearning spark ch07 - Running on a Cluster
Learning spark ch07 - Running on a Cluster
 
Learning spark ch06 - Advanced Spark Programming
Learning spark ch06 - Advanced Spark ProgrammingLearning spark ch06 - Advanced Spark Programming
Learning spark ch06 - Advanced Spark Programming
 
Learning spark ch05 - Loading and Saving Your Data
Learning spark ch05 - Loading and Saving Your DataLearning spark ch05 - Loading and Saving Your Data
Learning spark ch05 - Loading and Saving Your Data
 
Learning spark ch04 - Working with Key/Value Pairs
Learning spark ch04 - Working with Key/Value PairsLearning spark ch04 - Working with Key/Value Pairs
Learning spark ch04 - Working with Key/Value Pairs
 
Learning spark ch01 - Introduction to Data Analysis with Spark
Learning spark ch01 - Introduction to Data Analysis with SparkLearning spark ch01 - Introduction to Data Analysis with Spark
Learning spark ch01 - Introduction to Data Analysis with Spark
 
Hướng Dẫn Đăng Ký LibertaGia - A guide and introduciton about Libertagia
Hướng Dẫn Đăng Ký LibertaGia - A guide and introduciton about LibertagiaHướng Dẫn Đăng Ký LibertaGia - A guide and introduciton about Libertagia
Hướng Dẫn Đăng Ký LibertaGia - A guide and introduciton about Libertagia
 
Lecture 1 - Getting to know XML
Lecture 1 - Getting to know XMLLecture 1 - Getting to know XML
Lecture 1 - Getting to know XML
 
Lecture 4 - Adding XTHML for the Web
Lecture  4 - Adding XTHML for the WebLecture  4 - Adding XTHML for the Web
Lecture 4 - Adding XTHML for the Web
 

Io Streams

  • 1. JAVA I/O STREAMS NETWORK PROGRAMMING
  • 2.
  • 3.
  • 4.
  • 5. Input & Output Stream Hình 1: Chương trình xử lý dữ liệu từ 1 input stream Hình 2: Chương trình ghi dữ liệu ra output stream
  • 6. Trình tự đọc/ ghi dòng open input stream while (more information){ read information process information } close input stream open output stream while (more information){ get information from ... write information } close output stream Đọc thông tin từ input stream Ghi thông tin vào output stream
  • 7.
  • 8.
  • 11.
  • 13.
  • 14. Tổng quát về các Streams StringReader để đọc các ký tự từ một String trong bộ nhớ. StringWriter để ghi vào String . StringBufferInputStream tương tự như StringReader . Sự khác biệt chỉ là StringBufferInputStream đọc các bytes từ một đối tượng StringBuffer StringReader StringWriter StringBuffer- InputStream Đọc/ghi từ/vào bộ nhớ. Tạo stream từ một mảng, tiếp theo dùng các phương thức đọc/ghi để đọc/ghi từ/vào mảng. Tác vụ đọc sẽ lấy dữ liệu từ mảng Tác vụ ghi sẽ ghi ra mảng CharArrayReader CharArrayWriter ByteArrayInput- Stream ByteArrayOutput-Stream Memory Mô tả khái quát Streams I/O
  • 15. Tổng quát về các Streams Nối nhiều input streams thành một input stream. SequenceInput- Stream ( concatenation ) Nối Được gọi là các file streams. File streams dùng để đọc/ghi từ/vào file trên file system. FileReader FileWriter FileInputStream FileOutputStream File Hiện thực các thành phần input và output của một pipe. Pipes được dùng như một kênh truyền, nối output của một thread vào input của một thread khác. PipedReader PipedWriter PipedInputStream PipedOutputStream Pipe
  • 16. Tổng quát về các Streams Theo dõi số hàng trong khi đọc LineNumberReader LineNumberInput- Stream Counting Thuận tiện khi cần đọc/ghi các kiểu dữ liệu cơ bản ( primitive data types ) như int , double , ... DataInputStream DataOutputStream Chuyển đổi dạng dữ liệu ( Data Conver-sion ) Dùng khi cần lưu trữ, khôi phục, hoặc truyền toàn bộ đối tượng. ObjectInputStream ObjectOutputStream Object Serial- ization
  • 17. Tổng quát về các Streams Các lớp abstract này định nghĩa các giao tiếp cho các filter streams lọc dữ liệu trong khi đọc/ghi. FilterReader FilterWriter FilterInputStream FilterOutputStream Lọc dữ liệu ( Filtering ) Đệm dữ liệu trong các thao tác đọc/ghi. Đệm dữ liệu cải thiện tốc độ đọc ghi vì giảm số lần truy xuất thiết bị. BufferedReader BufferedWriter bufferedInput-Stream BufferedOutput-Stream Đệm ( Buffer-ing ) Rất thuận tiện khi cần kết xuất, dễ đọc với người. System.out là một đối tượng thuộc lớp PrintStream . PrintWriter PrintStream Printing
  • 18. Tổng quát về các Streams Cặp reader/writer này là cầu nối giữa các byte streams và character streams. Một InputStreamReader đọc các bytes từ một InputStream và chuyển các bytes đó thành các ký tự. Một OutputStreamWriter chuyển các ký tự sang các bytes, và ghi các bytes đó vào một OutputStream . Quá trình chuyển đổi sẽ sử dụng bộ mã mặc định nếu không được chỉ định rõ. Gọi System.getProperty ("file.encoding") để lấy về tên bộ mã mặc định. InputStreamReader OutputStreamWriter Chuyển đổi byte  ký tự ( Converting between Bytes and Characters )
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.
  • 71.
  • 72.
  • 73.
  • 74.
  • 75.
  • 76.
  • 77.
  • 78.
  • 79.
  • 80.
  • 81.
  • 82.
  • 83.
  • 84.
  • 85.  
  • 88.
  • 89.
  • 90.
  • 91.
  • 92.
  • 93.
  • 94.
  • 95.
  • 96.
  • 97.
  • 98.
  • 99.
  • 100.
  • 101.
  • 102.
  • 103.