Readers & Writers
Java 1.1 made some significant modifications to the fundamental I/O stream library. When you see the Reader and Writer classes, your first thought (like mine) might be that these were meant to replace the InputStream and OutputStream classes. But thats not the case. Although some aspects of the original streams library are deprecated (if you use them you will receive a warning from the compiler), the InputStream and OutputStream classes still provide valuable functionality in the form of byte-oriented I/O, whereas the Reader and Writer classes provide Unicode-compliant, character-based I/O. In addition:
1.1 added new classes into the InputStream and OutputStream
hierarchy, so its obvious those hierarchies werent being
- There are times when you must use classes from the byte
hierarchy in combination with classes in the character
hierarchy. To accomplish this, there are adapter classes:
InputStreamReader converts an InputStream to a Reader and
OutputStreamWriter converts an OutputStream to a Writer.
As is the practice in this book, I will attempt to provide an overview of the classes, but assume that you will use the JDK documentation to determine all the details, such as the exhaustive list of methods.