IO流—字符流
字符流 只能读写文本文件 Reader 抽象类 字符输出流的父类 Writer 抽象类 字符输出流的父类 字符转换输出流: OutputStreamWriter(OutputStream out): 创建使用默认字符编码的 OutputStreamWriter OutputStreamWriter(OutputStream out, String charsetName) : 创建使用指定字符集的 OutputStreamWriter 案例1: public class MyTest { public static void main(String[] args) throws IOException { //输出流,所关联的文件如果不存在则自动创建 OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream("a.txt")); //往文件中写入数据 out.write('你'); //一次写入一个字符 out.write('好'); out.flush(); //字符流要刷新一下 out.write('你'); //一次写入一个字符 out.write('好'); out.write('你'); //一次写入一个字符 out.write('好'); out.flush(); out.write(