Page 336 - computer science (868) class 11
P. 336
writeBytes() It writes a string to an output stream as a sequence of bytes.
writeChar() It writes a char to an output stream as a 2-byte value.
writeChars() It writes a string to an output stream as a sequence of characters.
writeFloat() It writes float-type data to an output stream.
writeInt() It writes integer data to an output stream.
writeDouble() It writes double-type data to an output stream.
writeLong() It writes long-type data to an output stream.
writeShort() It writes a short to the underlying output stream as two bytes, high byte first.
writeUTF() It writes String data to an output stream.
11.3.2 Character Stream
The character stream classes are used to create text files. These classes can handle 16-bit Unicode characters. They are
more advanced than byte stream classes as the byte stream classes can only handle 8-bit bytes and are not compatible
with the Unicode characters.
The input and output operations are handled by abstract classes named Reader and Writer respectively belonging
to java.io package. However, these classes cannot be directly used in the program. Some other classes which are
inherited from these classes are used to perform different read/write operations. The following diagram shows the
different classes inherited from the Reader and Writer classes.
Character Stream Classes
Reader Writer
BufferedReader FileReader InputStreamReader PrintWriter BufferedWriter FileWriter
Let us learn about them in detail.
Reader Class
The Reader class is abstract in nature which means it cannot be instantiated but it has subclasses that override its
methods and can read 16-bit characters from InputStream.
Some important classes that are inherited from the Reader class are described in the following table.
Class Description
BufferedReader It has methods to read characters from the buffer.
FileReader It has methods to read characters from the file.
InputStreamReader It has methods to convert byte streams to character streams.
Writer Class
The Writer class is also an abstract base class whose methods are implemented by its derived classes. Some of the
derived classes of the Writer class are described in the following table.
334334 Touchpad Computer Science-XI

