Summary of java stream classes

Java’s stream classes are good for streaming sequences of bytes, but
they’re not good for streaming sequences of characters because bytes and
characters are two different things. A byte represents an 8-bit data item
and a character represents a 16-bit data item. Also, Java’s char and String
types naturally handle characters instead of bytes. More importantly, byte
streams have no knowledge of character sets and their encodings.
Java provides writer and reader classes to stream characters. They support
character I/O (they work with char instead of byte) and take character
encodings into account. The abstract Writer and Reader classes describe
what it means to be a writer and a reader.
Writer and Reader are subclassed by OutputStreamWriter and
InputStreamReader, which bridge the gap between character and byte
streams. These classes are subclassed by the FileWriter and FileReader
convenience classes, which facilitate writing/reading characters to/from
files. Writer and Reader are also subclassed by BufferedWriter and
BufferedReader, which buffer characters for efficiency.

 

posted on 2016-04-19 15:25  rojas  阅读(219)  评论(0编辑  收藏  举报