1. 首先 所有的计算机存储设备,都是 把数据 搞成 二进制的字节 才能 存
写入和 读取都是 字节流, 字符流 只是 其一种包装
1.1 把字符串 写入 一个文件里面 ---使用的 字节流方式
String str="中国味";
fileOutPutStream dd=new FileOutPutStream(new File("1.txt"));
dd.write(str.getByte("utf-8"));
1.2 字符流的 写入就是
FileWrite fw=new FileWrite("1.txt");
fw.write(str);
fw.close();
1.3 字符流的 读取
FileRead fr=new fr("1.txt"); FileInputStream 类似的写法
char[] buf=new char[1024];
int ss= fr.read(buf) 把 数据读取出来 放到了 char[] 里面
new String(buf ,0,ss)---在 把 数组转化 为 字符串
1.4 BufferReader br=new BfR(new InputStr("1.txt"),"utf-8");
String dd=br.readLine() 直接读取一整行