SlideShare a Scribd company logo
1 of 3
streams
1.what is streams?
a)streams is a flowing data from one place to another place.but in java
applications readind and writing
data together called iostreams.
2.what is the advantage of streams?
a)streams is used to move a data from one place to another place.advantage of
streams is accept a data from
from input device and send a data to output device.
3.what are the types of IOstreams?
a)IOstreams are classified into two catagory
1.Byte streams.
2.character streams.
Byte Streams:
byte streams are used to transfer a data from location to another location in
form of byte by byte.
(or)
byte streams are used to readind and writing data inform of byte by byte
by using byte streams we can transfer any type of file like
text,vedio,audio....
Character Streams:
character streams are used to read and writting a data in form of character by
character.and each
character take two bytes of memory so spead of transfer a data in character
stream is spead compare
to byte streams.
using character streams we can send a only text files....
4.Byte streams classified into two types?
1.Input Streams
2.OutPut Streams
InputStreams:
this stream is used to perform the reading data from various resources inform of
byte by byte
eg:
1.FileInputStreams
2.DataInputStreams
OutPutStreams:
this stream is used to perform the writing operation into various resources in
form of byte by byte
eg:
1.FileOutPutStreams
2.DataOutPutStreams
5.Character Streams forther classifed into two types?
1.reading
2.writing
reading:
the reading similar to inputstreams to perform a reading operation from various
resources in form of character
by character.
eg:
file reading
writing:
the writing similar to outputstream to perform a writing operation into various
resource in form of character by
character
eg:
file writing
6.DataInputStream?
a)data input stream is one of the class used to reading a data from various
reasouces.
eg:
import java.io.DataInputStream;
import java.io.IOException;
class DataInputStreamDemo{
public static void main(String[] ar) throws IOException{
DataInputStream dis=new DataInputStream(System.in);
System.out.print("enter the characte:");
int ch;
while((ch=dis.read())!='1'){
System.out.print((char)ch);
}
}
}
7.ByteArrayInputStream?
a)this class is used to read the the data from byte array
syntax for creation:
ByteArrayInputStream bai=new ByteArrayInputStream(byte b[]);
eg:
import java.io.*;
import java.io.ByteArrayInputStream;
class ByteInputStreamDemo{
public static void main(String[] ar){
String s="rajasekhar";
byte bi[]=s.getBytes();
int ch;
ByteArrayInputStream bs=new ByteArrayInputStream(bi);
for(int i=0;i<1;i++){
while((ch=bs.read())!=-1){
System.out.print((char)ch);
}
bs.reset();
}
}
}
8.what is FileInputStream?
a)this class is used to read the data from the file in form of byte by byte.it
is possible to read data
from text file.
syntax:
FileInputStream fi=new FileInputStream("txt file");
eg:
import java.io.FileInputStream;
import java.io.IOException;
class FileInputStreamDemo{
public static void main(String[] ar) throws IOException{
FileInputStream fs=new FileInputStream("hi.txt");
System.out.println("the file content:");
int ch;
while((ch=fs.read())!=-1){
System.out.print((char)ch);
}
}
}
9.what is BufferedInputStreamReader?
a)this class is used to improve the performance of application by transfering an
application group of bytes
together.
before we saw in inputstream to transfer data in form of byte byte.but we use
bufferedinputstream we transfer group of bytes
at a time .
this class doesn't connect to resources directly and it takes supported of some
other inputstream
syntax:
BufferedInputStream bis=new BufferedInputStream(InputStream);
eg:
import java.io.FileInputStream;
import java.io.BufferedInputStream;
import java.io.IOException;
class FileInputStreamDemo{
public static void main(String[] ar) throws IOException{
FileInputStream fs=new FileInputStream("hi.txt");
BufferedInputStream bi=new BufferedInputStream(fs);
System.out.println("the file content:");
int ch;
while((ch=bi.read())!=-1){
System.out.print((char)ch);
}
}
}
10.what is file output stream?
a)this class is used to write the data into resource in form byte by byte.
syntax:
FileOutputStream fi=new FileOutputStream(file);
FileOutputStream fi=new FileOutputStream(string);
the above two syntax is used to write the content into specified file.if
specified file is not found then automatically
file will be created with the specified file.if the spacified file is alredy
available then it will be overide the already
existing with the new content.
eg:
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
class FileInputStreamDemo{
public static void main(String[] ar) throws IOException{
FileInputStream fs=new FileInputStream("hi.txt");
FileOutputStream fo=new FileOutputStream("one.txt");
//BufferedInputStream bi=new BufferedInputStream(fs);
System.out.println("the file content:");
int ch;
while((ch=fs.read())!=-1){
fo.write(ch);
}
fs.close();
fo.close();
}
}

More Related Content

What's hot

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
 
Buffer and scanner
Buffer and scannerBuffer and scanner
Buffer and scannerArif Ullah
 
Using Input Output
Using Input OutputUsing Input Output
Using Input Outputraksharao
 
IO In Java
IO In JavaIO In Java
IO In Javaparag
 
Java - File Input Output Concepts
Java - File Input Output ConceptsJava - File Input Output Concepts
Java - File Input Output ConceptsVicter Paul
 
Byte stream classes.49
Byte stream classes.49Byte stream classes.49
Byte stream classes.49myrajendra
 
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
 
Java Input and Output
Java Input and OutputJava Input and Output
Java Input and OutputDucat India
 
Java Input Output (java.io.*)
Java Input Output (java.io.*)Java Input Output (java.io.*)
Java Input Output (java.io.*)Om Ganesh
 
Chapter 10.3
Chapter 10.3Chapter 10.3
Chapter 10.3sotlsoc
 
File Input & Output
File Input & OutputFile Input & Output
File Input & OutputPRN USM
 
Chapter 12 - File Input and Output
Chapter 12 - File Input and OutputChapter 12 - File Input and Output
Chapter 12 - File Input and OutputEduardo Bergavera
 
Various io stream classes .47
Various io stream classes .47Various io stream classes .47
Various io stream classes .47myrajendra
 
File Handling in Java Oop presentation
File Handling in Java Oop presentationFile Handling in Java Oop presentation
File Handling in Java Oop presentationAzeemaj101
 
Character stream classes introd .51
Character stream classes introd  .51Character stream classes introd  .51
Character stream classes introd .51myrajendra
 

What's hot (20)

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
 
Buffer and scanner
Buffer and scannerBuffer and scanner
Buffer and scanner
 
Using Input Output
Using Input OutputUsing Input Output
Using Input Output
 
IO In Java
IO In JavaIO In Java
IO In Java
 
Handling I/O in Java
Handling I/O in JavaHandling I/O in Java
Handling I/O in Java
 
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
 
Byte stream classes.49
Byte stream classes.49Byte stream classes.49
Byte stream classes.49
 
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
 
Java Input and Output
Java Input and OutputJava Input and Output
Java Input and Output
 
Java I/O
Java I/OJava I/O
Java I/O
 
Java Input Output (java.io.*)
Java Input Output (java.io.*)Java Input Output (java.io.*)
Java Input Output (java.io.*)
 
Chapter 10.3
Chapter 10.3Chapter 10.3
Chapter 10.3
 
File Input & Output
File Input & OutputFile Input & Output
File Input & Output
 
Chapter 12 - File Input and Output
Chapter 12 - File Input and OutputChapter 12 - File Input and Output
Chapter 12 - File Input and Output
 
Various io stream classes .47
Various io stream classes .47Various io stream classes .47
Various io stream classes .47
 
File Handling in Java Oop presentation
File Handling in Java Oop presentationFile Handling in Java Oop presentation
File Handling in Java Oop presentation
 
Character stream classes introd .51
Character stream classes introd  .51Character stream classes introd  .51
Character stream classes introd .51
 
Files in java
Files in javaFiles in java
Files in java
 

Viewers also liked

Know your goverment (bubba)2654654654
Know your goverment (bubba)2654654654Know your goverment (bubba)2654654654
Know your goverment (bubba)2654654654mikey001562
 
Jesse Cabildo Portfolio
Jesse Cabildo PortfolioJesse Cabildo Portfolio
Jesse Cabildo Portfoliocabildoj
 
Продающий текст (в рамках вебинара центра Mediatk.ru)
Продающий текст (в рамках вебинара центра Mediatk.ru)Продающий текст (в рамках вебинара центра Mediatk.ru)
Продающий текст (в рамках вебинара центра Mediatk.ru)Вероника Кириллова
 
Продвижение персонального бренда в социальных медиа
Продвижение персонального бренда в социальных медиаПродвижение персонального бренда в социальных медиа
Продвижение персонального бренда в социальных медиаJulia Trushina
 
De las Tintas a los Pixels - El Diseño Gráfico Aplicado a la Web
De las Tintas a los Pixels - El Diseño Gráfico Aplicado a la WebDe las Tintas a los Pixels - El Diseño Gráfico Aplicado a la Web
De las Tintas a los Pixels - El Diseño Gráfico Aplicado a la WebNicolas Salinas
 
A la tierra
A la tierraA la tierra
A la tierraLUZ M.
 

Viewers also liked (7)

Know your goverment (bubba)2654654654
Know your goverment (bubba)2654654654Know your goverment (bubba)2654654654
Know your goverment (bubba)2654654654
 
Jesse Cabildo Portfolio
Jesse Cabildo PortfolioJesse Cabildo Portfolio
Jesse Cabildo Portfolio
 
Продающий текст (в рамках вебинара центра Mediatk.ru)
Продающий текст (в рамках вебинара центра Mediatk.ru)Продающий текст (в рамках вебинара центра Mediatk.ru)
Продающий текст (в рамках вебинара центра Mediatk.ru)
 
Продвижение персонального бренда в социальных медиа
Продвижение персонального бренда в социальных медиаПродвижение персонального бренда в социальных медиа
Продвижение персонального бренда в социальных медиа
 
De las Tintas a los Pixels - El Diseño Gráfico Aplicado a la Web
De las Tintas a los Pixels - El Diseño Gráfico Aplicado a la WebDe las Tintas a los Pixels - El Diseño Gráfico Aplicado a la Web
De las Tintas a los Pixels - El Diseño Gráfico Aplicado a la Web
 
A la tierra
A la tierraA la tierra
A la tierra
 
Elemen multimedia teks
Elemen multimedia teksElemen multimedia teks
Elemen multimedia teks
 

Similar to Inputstream

Similar to Inputstream (20)

Unit IV Notes.docx
Unit IV Notes.docxUnit IV Notes.docx
Unit IV Notes.docx
 
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
 
Io Streams
Io StreamsIo Streams
Io Streams
 
IO Streams, Serialization, de-serialization, autoboxing
IO Streams, Serialization, de-serialization, autoboxingIO Streams, Serialization, de-serialization, autoboxing
IO Streams, Serialization, de-serialization, autoboxing
 
Stream In Java.pptx
Stream In Java.pptxStream In Java.pptx
Stream In Java.pptx
 
Stream Based Input Output
Stream Based Input OutputStream Based Input Output
Stream Based Input Output
 
CORE JAVA-1
CORE JAVA-1CORE JAVA-1
CORE JAVA-1
 
Files io
Files ioFiles io
Files io
 
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
 
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?
 
L21 io streams
L21 io streamsL21 io streams
L21 io streams
 
Java I/O
Java I/OJava I/O
Java I/O
 
Basic of Javaio
Basic of JavaioBasic of Javaio
Basic of Javaio
 
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
 
Java Tutorial Lab 6
Java Tutorial Lab 6Java Tutorial Lab 6
Java Tutorial Lab 6
 
Io streams
Io streamsIo streams
Io streams
 
THE IO LIBRARY in C++
THE IO LIBRARY in C++THE IO LIBRARY in C++
THE IO LIBRARY in C++
 
Java Day-6
Java Day-6Java Day-6
Java Day-6
 

Inputstream

  • 1. streams 1.what is streams? a)streams is a flowing data from one place to another place.but in java applications readind and writing data together called iostreams. 2.what is the advantage of streams? a)streams is used to move a data from one place to another place.advantage of streams is accept a data from from input device and send a data to output device. 3.what are the types of IOstreams? a)IOstreams are classified into two catagory 1.Byte streams. 2.character streams. Byte Streams: byte streams are used to transfer a data from location to another location in form of byte by byte. (or) byte streams are used to readind and writing data inform of byte by byte by using byte streams we can transfer any type of file like text,vedio,audio.... Character Streams: character streams are used to read and writting a data in form of character by character.and each character take two bytes of memory so spead of transfer a data in character stream is spead compare to byte streams. using character streams we can send a only text files.... 4.Byte streams classified into two types? 1.Input Streams 2.OutPut Streams InputStreams: this stream is used to perform the reading data from various resources inform of byte by byte eg: 1.FileInputStreams 2.DataInputStreams OutPutStreams: this stream is used to perform the writing operation into various resources in form of byte by byte eg: 1.FileOutPutStreams 2.DataOutPutStreams 5.Character Streams forther classifed into two types? 1.reading 2.writing reading: the reading similar to inputstreams to perform a reading operation from various resources in form of character by character. eg: file reading writing: the writing similar to outputstream to perform a writing operation into various resource in form of character by character eg: file writing 6.DataInputStream? a)data input stream is one of the class used to reading a data from various reasouces. eg: import java.io.DataInputStream; import java.io.IOException; class DataInputStreamDemo{
  • 2. public static void main(String[] ar) throws IOException{ DataInputStream dis=new DataInputStream(System.in); System.out.print("enter the characte:"); int ch; while((ch=dis.read())!='1'){ System.out.print((char)ch); } } } 7.ByteArrayInputStream? a)this class is used to read the the data from byte array syntax for creation: ByteArrayInputStream bai=new ByteArrayInputStream(byte b[]); eg: import java.io.*; import java.io.ByteArrayInputStream; class ByteInputStreamDemo{ public static void main(String[] ar){ String s="rajasekhar"; byte bi[]=s.getBytes(); int ch; ByteArrayInputStream bs=new ByteArrayInputStream(bi); for(int i=0;i<1;i++){ while((ch=bs.read())!=-1){ System.out.print((char)ch); } bs.reset(); } } } 8.what is FileInputStream? a)this class is used to read the data from the file in form of byte by byte.it is possible to read data from text file. syntax: FileInputStream fi=new FileInputStream("txt file"); eg: import java.io.FileInputStream; import java.io.IOException; class FileInputStreamDemo{ public static void main(String[] ar) throws IOException{ FileInputStream fs=new FileInputStream("hi.txt"); System.out.println("the file content:"); int ch; while((ch=fs.read())!=-1){ System.out.print((char)ch); } } } 9.what is BufferedInputStreamReader? a)this class is used to improve the performance of application by transfering an application group of bytes together. before we saw in inputstream to transfer data in form of byte byte.but we use bufferedinputstream we transfer group of bytes at a time . this class doesn't connect to resources directly and it takes supported of some other inputstream syntax: BufferedInputStream bis=new BufferedInputStream(InputStream); eg: import java.io.FileInputStream; import java.io.BufferedInputStream; import java.io.IOException;
  • 3. class FileInputStreamDemo{ public static void main(String[] ar) throws IOException{ FileInputStream fs=new FileInputStream("hi.txt"); BufferedInputStream bi=new BufferedInputStream(fs); System.out.println("the file content:"); int ch; while((ch=bi.read())!=-1){ System.out.print((char)ch); } } } 10.what is file output stream? a)this class is used to write the data into resource in form byte by byte. syntax: FileOutputStream fi=new FileOutputStream(file); FileOutputStream fi=new FileOutputStream(string); the above two syntax is used to write the content into specified file.if specified file is not found then automatically file will be created with the specified file.if the spacified file is alredy available then it will be overide the already existing with the new content. eg: import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; class FileInputStreamDemo{ public static void main(String[] ar) throws IOException{ FileInputStream fs=new FileInputStream("hi.txt"); FileOutputStream fo=new FileOutputStream("one.txt"); //BufferedInputStream bi=new BufferedInputStream(fs); System.out.println("the file content:"); int ch; while((ch=fs.read())!=-1){ fo.write(ch); } fs.close(); fo.close(); } }