Java中的IO流是实现输入/输出的基础。
按照流的方向不同:分为输入流和输出流。
按照处理数据单位的不同:分为字节流(8位)和字符流(16位)。
按照功能不同:分为节点流和处理流
字符流:
字符流(Reader Writer)
字符的处理,一次处理一个字符(unicode 编码)
1: 字符的底层仍然是基本的字节流
2: 字符流的基本实现
3 :InputStreamReader 完成 byte 流解析为 char 流, 按照编码解析
4: OutputStreamWriter 提供 char 流到 byte 流, 按照编码处理
FileReader:以字符流的形式读取文件,与FileInputStream用法基本一致。
BufferedReader:将流读入缓冲区,然后从缓冲区读取,并且提供了readLine()方法,可以从文本文件中整行的读取数据。
Writer类中两个常用类:
FileWriter:以字符流的形式写入文件,与FileOutputStream用法基本一致。
BufferedWriter:将缓冲区输出到流