SlideShare una empresa de Scribd logo
1 de 13
• FileInputStream
• FileOutputStream
• InputStreamReader
• OutputStreamWriter
• FileReader
• FileWriter
Topic
FileInputStream
 Java FileInputStream class obtains input bytes from a file. It is
used for reading streams of raw bytes such as image data. For
reading stream of characters, consider using Filereader.
 It should be used to read byte-oriented data for example to read
Image, audio, video etc.
--------------
--------------
--------------
--------------
1100110011
Java
Application
f.txt
fin
Example :
import java.io.*;
class SimpleRead{
public static void main(String args[]){
try{
FileInputSteram fin=new FileInputStream("abc.txt");
int i=0;
while((i=fin.read())!='-1){
System.out.println((char)i);
}
fin.close();
}
catch(exception e){
system.out.println(e);
}
}
}
FileoutputStream
 Java FileOutputStream is an outputstream for writing data to a file.
 If you have to write primitive values then use FileOutputStream.instead,for
character-oriented data,prefer FileWriter.But you can write byte-oriented as
well as character-oriented data.
Java
Application
1100110011
---------------
---------------
---------------
---------------
fout
f.txt
Example :
import java.io.*;
class Test{
public static void main(String args[]){
try{
FileOutputStream fout=new FileOutputStream("abc.txt");
String s="Sachin Tendulkar is my favourite player";
byte b[]=s.getbytes();//converting string into byte array
fout.write(b);
fout.close();
System.out.println("success...");
} catch(Exception e)
{
System.out.println(e);
}
}
}
InputStreamReader
 The java.io.InputStreamReader class is a bridge from byte stream to
character stream.it reads bytes and decodes them into characters using a
specified charset.
S.N. Constructor & Description
1
InputStreamReader(InputStream in)
This creates an InputStreamReader that uses the default charset.
2
InputStreamReader(InputStream in, Charset cs)
This creates an InputStreamReader that uses the given charset.
3 InputStreamReader(InputStreamReader in,CharsetDecoder dec)
This creates an InputStreamReader that uses the given charset decoder
4 InputStreamReader(InputStream in, String charsetName)
This creates an InputStreamReader that uses the named charset.
• Methods:
S.N. Method & Desription
1 Void close()
This method close the stream and releases any system resources
Associated with it.
2 String getEncoding()
This method returns the name of the character encoding
Being used by this stream.
3 Int read()
This method reads a single character.
4 Int read(char[] cbuf,int offset,int length)
This method reads characters into a portion of an array.
5 Boolean ready()
This method tells whether this stream is ready to be read.
OutputStreamWriter
 The java.io.OutputStreamWriter class is a bridge from character streams to byte
streams.
 characters written to it are encoded into bytes using a specified charset.
• Constructors:
S.N. Constructor & Description
1
OutputStreamWriter(OutputStream out)
This creates an OutputStreamWriter that uses the default character encoding
2
OutputStreamWriter(OutputStream out, Charset cs)
This creates an outputStreamWriter that uses the given charset.
3 OutputStreamWriter(OutputStreamWriter out,CharsetEncoder enc)
This creates an OutputStreamWriter that uses the given charset encoder
4 OutputStreamWriter(OutputStream out, String charsetName)
This creates an OutputStreamWriter that uses the named charset.
• Methods:
S.N. Method & Desription
1 Void close()
This method close the stream,flushing it first.
2 Void flush()
This method flushes the stream.
3 Int read()
This method returns the name of the character encoding
Being used by this stream.
4 Void write(char[] cbuf,int off,int len)
This method writes a portion of an array of characters.
5 void write(int c)
This method writes a single character.
void write(string str,int off,int len)
This method writes a portion of a string.
6
Filereader
 This class inherits from the InputStreamReader class. FileReader is used for
reading streams of characters.
 This class has several constructors to create required objects. Below given are the list of
constructors provided by the FileReader class.
• Constructors:
S.N. Constructor & Description
1 FileReader(File file)
This constructor creates a new FileReader, given the File to read from.
2 FileReader(FileDescriptor fd)
This constructor creates a new FileReader, given the FileDescriptor to read from.
3 FileReader(String fileName)
This constructor creates a new FileReader, given the name of the file to read
from.
File Writer
 This class inherits from the OutputStreamWriter class. The class is used for
writing streams of characters.
 This class has serveral constructors to create required objects. Below
given is the list of them.
• Constructors:
S.N. Constructor & Description
1 FileWriter(File file)
This constructor creates a new FileWriter, given a File object.
2 FileWriter(File file, Boolean append)
This constructor creates a FileWriter object given a file object. With a Boolean
Indicating whether or not to append the data written.
3 FileReader(FileDescriptor fd)
This constructor creates a FileWriter object associated with the given file
descriptor
4 FileWriter(string fileName)
This constructor creates a FileWriter object, given a file name.
5 FileWriter(string filename, Boolean append)
This constructor creates a FileWriter object given a file name with a
Boolean indicating whether or not to append the data written.
• Methods:
S.N. Method with Desription
1 Public Void write(int c) throws ioException
Write a single character.
2 Public Void write(char [] c,int offset,int len)
Write a portion of an array of characters starting from offset and
with a length of len
3 Public Void write(String s,int off,int len)
Write a portion of a String starting from offset and with a length
of len
Java

Más contenido relacionado

La actualidad más candente

Java - File Input Output Concepts
Java - File Input Output ConceptsJava - File Input Output Concepts
Java - File Input Output ConceptsVicter Paul
 
Understanding java streams
Understanding java streamsUnderstanding java streams
Understanding java streamsShahjahan Samoon
 
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
 
[Java] #7 - Input & Output Stream
[Java] #7 - Input & Output Stream[Java] #7 - Input & Output Stream
[Java] #7 - Input & Output StreamGhadeer AlHasan
 
Java Input Output (java.io.*)
Java Input Output (java.io.*)Java Input Output (java.io.*)
Java Input Output (java.io.*)Om Ganesh
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in javaKavitha713564
 
I/O in java Part 1
I/O in java Part 1I/O in java Part 1
I/O in java Part 1ashishspace
 
IO In Java
IO In JavaIO In Java
IO In Javaparag
 
7 streams and error handling in java
7 streams and error handling in java7 streams and error handling in java
7 streams and error handling in javaJyoti Verma
 
IO and serialization
IO and serializationIO and serialization
IO and serializationbackdoor
 
L21 io streams
L21 io streamsL21 io streams
L21 io streamsteach4uin
 
14 file handling
14 file handling14 file handling
14 file handlingAPU
 
Input output files in java
Input output files in javaInput output files in java
Input output files in javaKavitha713564
 
Byte stream classes.49
Byte stream classes.49Byte stream classes.49
Byte stream classes.49myrajendra
 

La actualidad más candente (20)

Java - File Input Output Concepts
Java - File Input Output ConceptsJava - File Input Output Concepts
Java - File Input Output Concepts
 
Understanding java streams
Understanding java streamsUnderstanding java streams
Understanding java streams
 
Handling I/O in Java
Handling I/O in JavaHandling I/O in Java
Handling I/O in Java
 
File Input & Output
File Input & OutputFile Input & Output
File Input & Output
 
Java I/o streams
Java I/o streamsJava I/o streams
Java I/o streams
 
Java stream
Java streamJava stream
Java stream
 
Chapter 12 - File Input and Output
Chapter 12 - File Input and OutputChapter 12 - File Input and Output
Chapter 12 - File Input and Output
 
[Java] #7 - Input & Output Stream
[Java] #7 - Input & Output Stream[Java] #7 - Input & Output Stream
[Java] #7 - Input & Output Stream
 
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.*)
 
Files in java
Files in javaFiles in java
Files in java
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in java
 
I/O in java Part 1
I/O in java Part 1I/O in java Part 1
I/O in java Part 1
 
IO In Java
IO In JavaIO In Java
IO In Java
 
7 streams and error handling in java
7 streams and error handling in java7 streams and error handling in java
7 streams and error handling in java
 
IO and serialization
IO and serializationIO and serialization
IO and serialization
 
L21 io streams
L21 io streamsL21 io streams
L21 io streams
 
14 file handling
14 file handling14 file handling
14 file handling
 
Input output files in java
Input output files in javaInput output files in java
Input output files in java
 
Byte stream classes.49
Byte stream classes.49Byte stream classes.49
Byte stream classes.49
 

Similar a Java

Java program file I/O
Java program file I/OJava program file I/O
Java program file I/ONem Sothea
 
File Input and output.pptx
File Input  and output.pptxFile Input  and output.pptx
File Input and output.pptxcherryreddygannu
 
Input/Output Exploring java.io
Input/Output Exploring java.ioInput/Output Exploring java.io
Input/Output Exploring java.ioNilaNila16
 
File Handling in Java Oop presentation
File Handling in Java Oop presentationFile Handling in Java Oop presentation
File Handling in Java Oop presentationAzeemaj101
 
File Handling in Java.pdf
File Handling in Java.pdfFile Handling in Java.pdf
File Handling in Java.pdfSudhanshiBakre1
 
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
 
Stream In Java.pptx
Stream In Java.pptxStream In Java.pptx
Stream In Java.pptxssuser9d7049
 
Chapter 10.3
Chapter 10.3Chapter 10.3
Chapter 10.3sotlsoc
 
Java IO, Serialization
Java IO, Serialization Java IO, Serialization
Java IO, Serialization Hitesh-Java
 
Session 22 - Java IO, Serialization
Session 22 - Java IO, SerializationSession 22 - Java IO, Serialization
Session 22 - Java IO, SerializationPawanMM
 
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
 
Advanced programming ch2
Advanced programming ch2Advanced programming ch2
Advanced programming ch2Gera Paulos
 
CSE3146-ADV JAVA M2.pdf
CSE3146-ADV JAVA M2.pdfCSE3146-ADV JAVA M2.pdf
CSE3146-ADV JAVA M2.pdfVithalReddy3
 
Buffer and scanner
Buffer and scannerBuffer and scanner
Buffer and scannerArif Ullah
 
inputoutputstreams-140612032817-phpapp02.pdf
inputoutputstreams-140612032817-phpapp02.pdfinputoutputstreams-140612032817-phpapp02.pdf
inputoutputstreams-140612032817-phpapp02.pdfhemanth248901
 

Similar a Java (20)

Java Day-6
Java Day-6Java Day-6
Java Day-6
 
Java program file I/O
Java program file I/OJava program file I/O
Java program file I/O
 
File Input and output.pptx
File Input  and output.pptxFile Input  and output.pptx
File Input and output.pptx
 
Io Streams
Io StreamsIo Streams
Io Streams
 
Input/Output Exploring java.io
Input/Output Exploring java.ioInput/Output Exploring java.io
Input/Output Exploring java.io
 
IOStream.pptx
IOStream.pptxIOStream.pptx
IOStream.pptx
 
File Handling in Java Oop presentation
File Handling in Java Oop presentationFile Handling in Java Oop presentation
File Handling in Java Oop presentation
 
Unit IV Notes.docx
Unit IV Notes.docxUnit IV Notes.docx
Unit IV Notes.docx
 
File Handling in Java.pdf
File Handling in Java.pdfFile Handling in Java.pdf
File Handling in Java.pdf
 
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
 
Stream In Java.pptx
Stream In Java.pptxStream In Java.pptx
Stream In Java.pptx
 
Chapter 10.3
Chapter 10.3Chapter 10.3
Chapter 10.3
 
Java IO, Serialization
Java IO, Serialization Java IO, Serialization
Java IO, Serialization
 
Session 22 - Java IO, Serialization
Session 22 - Java IO, SerializationSession 22 - Java IO, Serialization
Session 22 - Java IO, Serialization
 
05io
05io05io
05io
 
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
 
Advanced programming ch2
Advanced programming ch2Advanced programming ch2
Advanced programming ch2
 
CSE3146-ADV JAVA M2.pdf
CSE3146-ADV JAVA M2.pdfCSE3146-ADV JAVA M2.pdf
CSE3146-ADV JAVA M2.pdf
 
Buffer and scanner
Buffer and scannerBuffer and scanner
Buffer and scanner
 
inputoutputstreams-140612032817-phpapp02.pdf
inputoutputstreams-140612032817-phpapp02.pdfinputoutputstreams-140612032817-phpapp02.pdf
inputoutputstreams-140612032817-phpapp02.pdf
 

Último

Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)simmis5
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college projectTonystark477637
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 

Último (20)

Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 

Java

  • 1. • FileInputStream • FileOutputStream • InputStreamReader • OutputStreamWriter • FileReader • FileWriter Topic
  • 2. FileInputStream  Java FileInputStream class obtains input bytes from a file. It is used for reading streams of raw bytes such as image data. For reading stream of characters, consider using Filereader.  It should be used to read byte-oriented data for example to read Image, audio, video etc. -------------- -------------- -------------- -------------- 1100110011 Java Application f.txt fin
  • 3. Example : import java.io.*; class SimpleRead{ public static void main(String args[]){ try{ FileInputSteram fin=new FileInputStream("abc.txt"); int i=0; while((i=fin.read())!='-1){ System.out.println((char)i); } fin.close(); } catch(exception e){ system.out.println(e); } } }
  • 4. FileoutputStream  Java FileOutputStream is an outputstream for writing data to a file.  If you have to write primitive values then use FileOutputStream.instead,for character-oriented data,prefer FileWriter.But you can write byte-oriented as well as character-oriented data. Java Application 1100110011 --------------- --------------- --------------- --------------- fout f.txt
  • 5. Example : import java.io.*; class Test{ public static void main(String args[]){ try{ FileOutputStream fout=new FileOutputStream("abc.txt"); String s="Sachin Tendulkar is my favourite player"; byte b[]=s.getbytes();//converting string into byte array fout.write(b); fout.close(); System.out.println("success..."); } catch(Exception e) { System.out.println(e); } } }
  • 6. InputStreamReader  The java.io.InputStreamReader class is a bridge from byte stream to character stream.it reads bytes and decodes them into characters using a specified charset. S.N. Constructor & Description 1 InputStreamReader(InputStream in) This creates an InputStreamReader that uses the default charset. 2 InputStreamReader(InputStream in, Charset cs) This creates an InputStreamReader that uses the given charset. 3 InputStreamReader(InputStreamReader in,CharsetDecoder dec) This creates an InputStreamReader that uses the given charset decoder 4 InputStreamReader(InputStream in, String charsetName) This creates an InputStreamReader that uses the named charset.
  • 7. • Methods: S.N. Method & Desription 1 Void close() This method close the stream and releases any system resources Associated with it. 2 String getEncoding() This method returns the name of the character encoding Being used by this stream. 3 Int read() This method reads a single character. 4 Int read(char[] cbuf,int offset,int length) This method reads characters into a portion of an array. 5 Boolean ready() This method tells whether this stream is ready to be read.
  • 8. OutputStreamWriter  The java.io.OutputStreamWriter class is a bridge from character streams to byte streams.  characters written to it are encoded into bytes using a specified charset. • Constructors: S.N. Constructor & Description 1 OutputStreamWriter(OutputStream out) This creates an OutputStreamWriter that uses the default character encoding 2 OutputStreamWriter(OutputStream out, Charset cs) This creates an outputStreamWriter that uses the given charset. 3 OutputStreamWriter(OutputStreamWriter out,CharsetEncoder enc) This creates an OutputStreamWriter that uses the given charset encoder 4 OutputStreamWriter(OutputStream out, String charsetName) This creates an OutputStreamWriter that uses the named charset.
  • 9. • Methods: S.N. Method & Desription 1 Void close() This method close the stream,flushing it first. 2 Void flush() This method flushes the stream. 3 Int read() This method returns the name of the character encoding Being used by this stream. 4 Void write(char[] cbuf,int off,int len) This method writes a portion of an array of characters. 5 void write(int c) This method writes a single character. void write(string str,int off,int len) This method writes a portion of a string. 6
  • 10. Filereader  This class inherits from the InputStreamReader class. FileReader is used for reading streams of characters.  This class has several constructors to create required objects. Below given are the list of constructors provided by the FileReader class. • Constructors: S.N. Constructor & Description 1 FileReader(File file) This constructor creates a new FileReader, given the File to read from. 2 FileReader(FileDescriptor fd) This constructor creates a new FileReader, given the FileDescriptor to read from. 3 FileReader(String fileName) This constructor creates a new FileReader, given the name of the file to read from.
  • 11. File Writer  This class inherits from the OutputStreamWriter class. The class is used for writing streams of characters.  This class has serveral constructors to create required objects. Below given is the list of them. • Constructors: S.N. Constructor & Description 1 FileWriter(File file) This constructor creates a new FileWriter, given a File object. 2 FileWriter(File file, Boolean append) This constructor creates a FileWriter object given a file object. With a Boolean Indicating whether or not to append the data written. 3 FileReader(FileDescriptor fd) This constructor creates a FileWriter object associated with the given file descriptor 4 FileWriter(string fileName) This constructor creates a FileWriter object, given a file name. 5 FileWriter(string filename, Boolean append) This constructor creates a FileWriter object given a file name with a Boolean indicating whether or not to append the data written.
  • 12. • Methods: S.N. Method with Desription 1 Public Void write(int c) throws ioException Write a single character. 2 Public Void write(char [] c,int offset,int len) Write a portion of an array of characters starting from offset and with a length of len 3 Public Void write(String s,int off,int len) Write a portion of a String starting from offset and with a length of len