Reading Writing Text  «Prev  Next»


Lesson 16

Data Composed of Characters

Java Input Output Text Conclusion

This discussed the basics of handling input and output of text (data composed of characters rather than raw bytes) using readers and writers.
You learned that data manipulation of text input and output in Java is not really that different from byte-oriented input and output.
However, depending on the encoding used, the same sequence of bytes can have two completely different meanings in two different character sets, so it is important to know with what character set you are working.
The java.io.Reader and java.io.Writer classes and their various subclasses can handle the necessary conversions between the different character sets and the Unicode Java uses internally.
You also learned about using the FileReader and FileWriter classes to read and write text files.

The java.io package also contains two deprecated classes that are not shown in the preceding table:
  1. LineNumberInputStream and
  2. StringBufferInputStream.
These classes should not be used for new code.
The following interfaces are defined by java.io:
Java IO Interfaces
Java IO Interfaces

As you can see, there are many classes and interfaces in the java.io package.
These include byte and character streams, and object serialization (the storage and retrieval of objects). This module examined several commonly used I/O components. We begin our discussion with one of the most distinctive I/O classes.
In the next module, you will learn about the different types of readers and writers, including the
  1. BufferedReader and BufferedWriter classes
  2. StringReader and StringWriter classes
  3. CharArrayReader and CharArrayWriter classes

You will also learn how to write subclasses of FilterReader and FilterWriter that manipulate text before passing it on.

Java I/O