At this point, you may be caught in a dilemma, wondering if there is another design for IO flow and may require a greater amount of code. Can anyone suggest a more bizarre design? In fact, Java 1.1 has made some significant improvements to the IO stream library. When you see reader and writer classes, most people's first impression (as I do) is that they are used to replace the original InputStream and OutputStream classes. But the truth is not so. Although some features of the original data stream library are not recommended (such as using them, a warning message is received from the compiler), the original data stream is retained to maintain backward compatibility and:
(1) New classes are added to the old hierarchy, so sun is clearly not abandoning the old data stream.
(2) In many cases, we need to use classes in the old structure in conjunction with the classes in the new structure. To achieve this, you need to use some "bridge" classes: InputStreamReader converts a inputstream into a reader,outputstreamwriter converts a outputstream to writer.
Therefore, compared with the original IO stream library, the new IO stream is often more layered. Likewise, this is a disadvantage of the adorner scheme-the need to pay for additional flexibility.
The most important reason for adding reader and writer levels to Java 1.1 is the need for internationalization. The old IO flow hierarchy supports only 8-bit byte streams and does not control 16-bit Unicode characters well. Because Unicode is primarily oriented towards internationalization support (Java-contained char is 16-bit Unicode), the reader and writer levels are added to provide support for Unicode in all IO operations. In addition, the new library is optimized for speed, which runs faster than the old library.
As elsewhere in this book, I will try to provide an overview of the class, but assume that you'll use the online documentation to get all the details, such as a detailed list of methods.