字符流与字节流小结

Ban

Ban

ChangAn University
info

字节流继承于InputStream OutputStream,字符流继承于InputStreamReader OutputStreamWriter

后缀是Stream的都是字节流,其他的都是字符流

可以理解为字符流=字节流+编码集

字节流:

InputStream
|-- FileInputStream (基本文件流)
|-- BufferedInputStream
|-- DataInputStream
|-- ObjectInputStream

字符流

Reader
|-- InputStreamReader (byte->char 桥梁)
|-- BufferedReader (常用)
Writer
|-- OutputStreamWriter (char->byte 桥梁)
|-- BufferedWriter
|-- PrintWriter (常用)