Reading Writing Text  «Prev 


Java Reader and Writer Classes

Just because Java can work with these character sets internally does not mean your host platform can actually display them. On most platforms System.out can only handle ASCII or perhaps ISO Latin-1. TextAreas, TextFields, Labels, and other GUI components may be somewhat more versatile, but you can not count on this.
Some versions of Netscape can handle some extended Latin characters and a few others.
Sun (now Oracle) had a version of HotJava and the JDK that works with Japanese. No Java environment I am familiar with even attempts to properly display Chinese.
To bring data into a program, a Java program opens a stream to a data source, such as a file or remote socket, and reads the information serially. On the flip side, a program can open a stream to a data source and write to it in a serial fashion. Whether you are reading from a file or from a socket, the concept of serially reading from, and writing to different data sources is the same. For that very reason, once you understand the top level classes (java.io.Reader, java.io.Writer), the remaining classes are straightforward to work with.

The Java Reader (java.io.Reader) and Java Writer class (java.io.Writer) in Java IO work much like the InputStream and OutputStream with the exception that Reader and Writer are character based. They are intended for reading and writing text. The InputStream and OutputStream are byte based.
For Java Input/Output, Streams access sequences of bytes, while readers and writers access sequences of characters.