SlideShare a Scribd company logo
FILES STREAMS
SYNOPSIS:
 FILES
 STREAM
 INPUT STREAM
 OUTPUT STREAM
 SEREALIZATION
FILES:
 It is a collection of data
 In which collection of informations are
stored.
STREAM:
 A stream is a sequence of data. In Java, a
stream is composed of bytes. It's called a
stream because it is like a stream of water
that continues to flow.
Cntd….
In Java, 3 streams are created for us
automatically. All these streams are attached with
the console.
1) System.out : standard output stream
2) System.in: standard input stream
3) System.err : standard error stream
TYPES OF STREAMS:
There are two types of streams:
1. Input Stream – It reads data from the
source.
2. Output Stream – It writes data to the
destination.
INPUT STREAM
 Input Stream class is the superclass of all the
io classes i.e. representing an input stream
of bytes. It represents input stream of bytes.
Applications that are defining subclass of
Input Stream must provide method, returning
the next byte of input.
A reset() method is invoked which re-
positions the stream to the recently marked
position.
EXAMPLE
import java.io.FileInputStream;
public class DataStreamExample {
public static void main(String args[]){
try{
FileInputStream fin=new FileInputStream("D:testout.txt
");
int i=fin.read();
System.out.print((char)i);
fin.close();
}catch(Exception e){System.out.println(e);}
}
}
OUTPUT STREAM
 This abstract class is the superclass of all
classes representing an output stream of
bytes. An output stream accepts output bytes
and sends them to some sink.
Applications that need to define a subclass of
OutputStream must always provide at least a
method that writes one byte of output.
EXAMPLE
import java.io.*;
class OutputStreamDemo
{
public static void main(String args[])throws Exception
{
OutputStream os = new FileOutputStream("file.txt");
byte b[] = {65, 66, 67, 68, 69, 70};
os.write(b);
os.flush();
for (int i = 71; i <75 ; i++)
{
os.write(i);
}
os.flush();
os.close();
}
}
RANDOM ACCESS FILE:
 Files in which records can be accessed
in any order.it is also called direct
access file.
SERIEALIZATION:
 Serialization is a mechanism of converting
the state of an object into a byte stream.

More Related Content

DOCX
Filehandling
PPTX
Test Program - Basic operators
PPTX
TXT
Inputstream
PDF
Java Week4(B) Notepad
PDF
Chapter28 data-file-handling
PPTX
[Java] #7 - Input & Output Stream
PPTX
Stream classes in C++
Filehandling
Test Program - Basic operators
Inputstream
Java Week4(B) Notepad
Chapter28 data-file-handling
[Java] #7 - Input & Output Stream
Stream classes in C++

What's hot (18)

PDF
What is java input and output stream?
PPTX
Java I/O
PPTX
2CPP17 - File IO
PPT
Java Input Output and File Handling
PPTX
Managing console i/o operation,working with files
PPT
Data file handling
PPT
working file handling in cpp overview
PDF
PPT
17 files and streams
PDF
Basics of files and its functions with example
PPTX
Files and streams In Java
PPT
File Input & Output
PPTX
15. text files
PPTX
Introduction to c_plus_plus (6)
PPTX
Java8: what's new and what's hot
PPT
Filehandlinging cp2
PPT
C++ files and streams
What is java input and output stream?
Java I/O
2CPP17 - File IO
Java Input Output and File Handling
Managing console i/o operation,working with files
Data file handling
working file handling in cpp overview
17 files and streams
Basics of files and its functions with example
Files and streams In Java
File Input & Output
15. text files
Introduction to c_plus_plus (6)
Java8: what's new and what's hot
Filehandlinging cp2
C++ files and streams
Ad

Similar to Files streams.. (20)

PDF
inputoutputstreams-140612032817-phpapp02.pdf
PPT
Input output streams
PPT
Various io stream classes .47
PPT
Various io stream classes .47
PDF
javaiostream
PDF
Javaiostream
PPTX
Chapter 6
PDF
What is java input and output stream?
DOC
Web Technology Web Technology Notes Streams Network Principles and SocketsUni...
PPTX
Java programming Chapter 4.pptx
PPTX
Java Input Output (java.io.*)
PPT
Md121 streams
PDF
Monhocvecaujahetvagiuplaptunhhayhonha.pdf
PPT
Jedi Slides Intro2 Chapter12 Advanced Io Streams
PDF
Java - File Input Output Concepts
PPTX
1.26 File Input-Output in JAVA.pptx
PPTX
Files io
PDF
11_Str11_Streams.11_Streams.11_Streams.11_Streams.11_Streams.11_Streams.eams.pdf
inputoutputstreams-140612032817-phpapp02.pdf
Input output streams
Various io stream classes .47
Various io stream classes .47
javaiostream
Javaiostream
Chapter 6
What is java input and output stream?
Web Technology Web Technology Notes Streams Network Principles and SocketsUni...
Java programming Chapter 4.pptx
Java Input Output (java.io.*)
Md121 streams
Monhocvecaujahetvagiuplaptunhhayhonha.pdf
Jedi Slides Intro2 Chapter12 Advanced Io Streams
Java - File Input Output Concepts
1.26 File Input-Output in JAVA.pptx
Files io
11_Str11_Streams.11_Streams.11_Streams.11_Streams.11_Streams.11_Streams.eams.pdf
Ad

Recently uploaded (20)

PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PPTX
Cell Types and Its function , kingdom of life
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
RMMM.pdf make it easy to upload and study
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Complications of Minimal Access Surgery at WLH
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
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
Classroom Observation Tools for Teachers
PPTX
GDM (1) (1).pptx small presentation for students
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Cell Types and Its function , kingdom of life
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
RMMM.pdf make it easy to upload and study
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
human mycosis Human fungal infections are called human mycosis..pptx
Microbial disease of the cardiovascular and lymphatic systems
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Renaissance Architecture: A Journey from Faith to Humanism
O7-L3 Supply Chain Operations - ICLT Program
VCE English Exam - Section C Student Revision Booklet
Complications of Minimal Access Surgery at WLH
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
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Classroom Observation Tools for Teachers
GDM (1) (1).pptx small presentation for students
102 student loan defaulters named and shamed – Is someone you know on the list?

Files streams..

  • 2. SYNOPSIS:  FILES  STREAM  INPUT STREAM  OUTPUT STREAM  SEREALIZATION
  • 3. FILES:  It is a collection of data  In which collection of informations are stored.
  • 4. STREAM:  A stream is a sequence of data. In Java, a stream is composed of bytes. It's called a stream because it is like a stream of water that continues to flow.
  • 5. Cntd…. In Java, 3 streams are created for us automatically. All these streams are attached with the console. 1) System.out : standard output stream 2) System.in: standard input stream 3) System.err : standard error stream
  • 6. TYPES OF STREAMS: There are two types of streams: 1. Input Stream – It reads data from the source. 2. Output Stream – It writes data to the destination.
  • 7. INPUT STREAM  Input Stream class is the superclass of all the io classes i.e. representing an input stream of bytes. It represents input stream of bytes. Applications that are defining subclass of Input Stream must provide method, returning the next byte of input. A reset() method is invoked which re- positions the stream to the recently marked position.
  • 8. EXAMPLE import java.io.FileInputStream; public class DataStreamExample { public static void main(String args[]){ try{ FileInputStream fin=new FileInputStream("D:testout.txt "); int i=fin.read(); System.out.print((char)i); fin.close(); }catch(Exception e){System.out.println(e);} } }
  • 9. OUTPUT STREAM  This abstract class is the superclass of all classes representing an output stream of bytes. An output stream accepts output bytes and sends them to some sink. Applications that need to define a subclass of OutputStream must always provide at least a method that writes one byte of output.
  • 10. EXAMPLE import java.io.*; class OutputStreamDemo { public static void main(String args[])throws Exception { OutputStream os = new FileOutputStream("file.txt"); byte b[] = {65, 66, 67, 68, 69, 70}; os.write(b); os.flush(); for (int i = 71; i <75 ; i++) { os.write(i); } os.flush(); os.close(); } }
  • 11. RANDOM ACCESS FILE:  Files in which records can be accessed in any order.it is also called direct access file.
  • 12. SERIEALIZATION:  Serialization is a mechanism of converting the state of an object into a byte stream.