0% found this document useful (0 votes)
46 views

Presented By: Fayiza Beegam.P

The document discusses character stream classes in Java. It describes Reader and Writer classes, which handle Unicode character streams. Reader classes are used to read 16-bit Unicode characters from an input stream, with subclasses like BufferedReader and FileReader. Writer classes are used to write characters to an output stream, with subclasses like BufferedWriter and FileWriter. The BufferedReader and BufferedWriter classes create buffered character streams to improve performance.

Uploaded by

Fayiza beegam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views

Presented By: Fayiza Beegam.P

The document discusses character stream classes in Java. It describes Reader and Writer classes, which handle Unicode character streams. Reader classes are used to read 16-bit Unicode characters from an input stream, with subclasses like BufferedReader and FileReader. Writer classes are used to write characters to an output stream, with subclasses like BufferedWriter and FileWriter. The BufferedReader and BufferedWriter classes create buffered character streams to improve performance.

Uploaded by

Fayiza beegam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 11

PRESENTED BY

FAYIZA BEEGAM.P
CHARACTER STREAM CLASSES


 The java platform stores character values using
Unicode conventions.
 Character stream I/O automatically translates this
internal format to and form the local character set.
 Character streams are defined by using two class
hierarchies.
 At the top are two abstract classes, Reader and writer
class.
 These abstract classes handle Unicode character
streams.
READER CLASSES


 Reader classes are used to read 16-bit Unicode
characters from the input stream.
 Superclass for all character-oriented input stream
classes.
 Being an abstract class, Reader class cannot be
instantiated hence it’s subclasses are used.
 All methods of this class throw an I/O Exception.
Class Description
Buffered Reader Contains methods to read
characters from the buffer
CharArrayReader Contains methods to read
characters from a character array
FileReader Contains methods to read from a
file
FilterReader Contains methods to read from
underlying character –input stream
InputStreamReader Contains methods to convert byte to
characters
PipedReader Contains methods to read from the
connected piped output stream
StringReader Contains methods to read from a
string
Methods Description
voidwrite() Write data to the output
stream
Voidwrite(int i) Write a single characters to the
output stream
Voidwrite(char buffer[]) Write an array of characters to
the output stream
void write(char buffer[],int Writes ‘n’ characters from the
loc,int nChars) buffer starting at buffer[loc] to
the output stream

Void close() Close the output stream.if an


attempt is made to perform
writing operation even after
closing the stream then it
generates I/O Exceptions

Void flush() Flushes the ouput stream and


writes the waiting buffered
output characters
Using BufferedReader class:-

 Buffered Reader class creates buffered characters streams


between the
input device and the program.

 The BufferedReader object can be created using one of the following


two constructors.
a) BufferedReader(Reader inpStream)
b) BufferedReader(Reader inpStream, int nChars)

 First constructor creates a buffered character stream of default buffer size.

 Second constructor creates a buffered character stream that uses an input


buffer of size nChars.
WRITER CLASS


 Writer classes are used to write 16-bit Unicode
characters onto an output stream.
 The writer classes is the superclass for all character-
oriented output stream classes.
 All the methods of this class throw an I/O
Eexception.
 Being an abstract class, the writer class cannot be
instantiated hence,it’s subclasses are used.
Class Description

BufferedWriter Contains methods to write


characters to a buffer
FileWriter Contains methods to write
to a file
FilterWriter Contains methods to write
characters to underlying
output stream
CharArrayWriter Contains methods to write
characters to a character
array
OutputStreamWriter Contains methods to
convert from bytes to
characters
PipedWriter Contains methods to the
connected piped input
stream
StringWriter Contains methods to write
to a string
Writer class methods:-

Method Description
Void write() Writes data to the stream
Void write(int i) Write a single character to
the output stream
Void write(char buffer[]) Writes an array of
characters to the output
stream
Void write(char buffer[],int Write ’n’ characters from
loc,int nChars) the buffer starting at
buffer[loc] to the output
stream
Void close() Close the output stream
Void flush() Flushes the output stream
and writes the waiting
buffered output characters
Using BufferedWriter class:-


 The BufferedReader class,an output counterpart of
the BufferedReader,is used to write characters onto
the character-output stream.
 The BufferReader object can be created one of the
following two constructors.
a) BufferedWriter(writer outStream)
b) BufferedWriter(writer outStream, int n Chars)
 The first constuctor creates a buffered character
stream that uses an input buffer of size nChars.
THANKS

You might also like