Stream、Reader和Writer
InputStream/OutputStream:1)是所有的输入和输入类的基类。
Reader/Writer:面向字符的I/O操作(16位的Unicode字符)
兼容Unicode
InputStreamReader:可以将InputStream转换为Reader
OutputStreamWriter:可以将OutputStream转换为Writer
Java1.0类与java1.1类的对应表1
InputStream对应Reader
OutputStream对应Writer
FileInputStream对应FileReader
FileOutputStream对应FileWriter
StringBufferInputStream对应StringReader
无对应StringWriter
ByteArrayInputStream对应CharArrayReader
ByteArrayOutputStream对应CharArrayWriter
应该尽可能使用Reader和Writer类。
Java1.0类与java1.1类的对应表2
FilterInputStream对应FilterReader
FilterOutputStream对应FilterWriter
BufferedInputStream对应BufferedReader
BufferedOutputStream对应BufferedWriter
DataInputStream
PrintStream对应PrintWriter
DataInputStream和DataOutputStream价值在于无论在于什么样的平台java都可以准配的写入和读取数据。在写字符串并且让DateOutputStream能够恢复唯一可靠的方法是使用Unicode-8编码(DataOutputStream的writeUTF方法)
I/O的重定向方法:setIn(InputStream), setOut(OutputStream), setErr(OutputStream)