Streams, Readers, and Writers

Back Up Next

 

InputStreams, OutputStreams, Readers and Writers
What's the difference between the Input/Output Streams and Readers/Writers?
Input/Output Streams use bytes (8bits) as data (and its limitations)
Readers/Writers use chars (16bits) as data (which supports Unicode)
Thus, Readers and Writers are foreign-language-friendly and is an important internationalization feature in Java 1.1 and later
Use InputStreamReader and OutputStreamWriter to convert from Streams to Reader/Writer
This is the preferred way for conversions - these two classes handle the translation from bytes into Unicode characters according to the particular platform and locale dependent character encoding
Common I/O classes
BufferedReader/Writer and Buffered[Input, Output]Stream - buffer data to improve efficiency
FileReader/Writer and File[Input, Output]Stream - read/write to files
Object[Input, Output]Stream - (de)serialize objects from/to streams