字符流:读取文件时是以字符为基础的
1.小文件的IO(大文件的IO跟字节流的写法参照字节流的大文件IO的写法)
import java.io.*;
class TestIO{
public static void main(String args []){
FileReader fr = null;
FileWriter fw = null;
try{
fr = new FileReader("F:/javastudy/src/form.txt");
fw = new FileWriter("F:/javastudy/src/to.txt");
char [] buffer = new char[100];
//参数:char类型的数组(字符读取进来存放的地方),int类型(字符在数组中开始存放的位置),
//int类型(每次读取字符的个数)
int temp = fr.read(buffer,0,buffer.length);
fw.write(buffer,0,temp);
}catch(Exception e){
System.out.println(e);
}finally{
try{
fr.close();
fw.close();
}catch(Exception e){
System.out.println(e);
}
}
}
}