In this section we will discuss the I/O Character Streams.
Character streams works with the characters rather than the byte. In Java characters are stored by following the Unicode (allows a unique number for every character) conventions. In such kind of storage characters becomes the platform independent, program independent, language independent. Characters storage using Unicode convention makes the Java ready for internationalization and for this Java provides the Character stream I/O. Character stream I/O is helpful for internationalization because it automatically translated the internal format to and from the local character set.
In Java to facilitate the character stream I/O the character stream classes are defined. These classes are drawn from the Reader and Writer classes. Both of these classes are abstract classes. where the Reader class is used for input (read from) and the Writer class is used for output (write to). To work with the file I/O specialized classes are the FileReader and FileWriter.
Reader : An abstract class that facilitate to take input
(read) the character stream. Subclasses of this class must have to implement the
read(char, int, int) and close() methods.
public abstract class Reader extends Object implements Readable, Closeable
Some subclasses of the Reader class are given into table :
|BufferedReader||BufferedReader class provides the facility to read texts from a character-input stream using buffer.|
|CharArrayReader||CharArrayReader implements the character buffer to read character stream.|
|FilterReader||This class is used for reading the filtered character streams.|
|InputStreamReader||This class acts as a bridge from byte streams to character streams.|
|PipedReader||Piped character input stream|
|StringReader||Character stream read from the String|
Writer : An abstract class that facilitate to write
character streams. Subclasses of this class must have to implement the
write(char, int, int), flush() and close() methods.
public abstract class Writer extends Object implements Appendable, Closeable, Flushable
Some subclasses of Writer class are as follows :
|BufferedWriter||BufferedWriter class provides the facility to write texts to a character-output stream using buffer.|
|CharArrayWriter||CharArrayWriter implements the character buffer to write character stream.|
|FilterWriter||This class is used for writing the filtered character streams.|
|OutputStreamWriter||This class acts as a bridge from character streams to byte streams.|
|PipedWriter||Piped character output stream|
|PrintWriter||This class is used to write the formatted representation of objects to a text output stream.|
|StringWriter||This class writes a constructed string. String is constructed after
collecting the output of a
character stream into a buffer.
If you enjoyed this post then why not add us on Google+? Add us to your Circles
Liked it! Share this Tutorial
Discuss: Java I/O Character Streams
Post your Comment