// 纯文本的读写操作 ,优先考虑字符流
public void readerAndWriter(){
// 创建字符流的读写对象try {
FileReader fr=new FileReader("h:/a.txt");
FileWriter fw=new FileWriter("h:/c.txt");
char [] cs=new char[1024];
long start =System.currentTimeMillis();
// 读写操作
int len= fr.read(cs);
while(len!=-1){
fw.write(cs,0,len);
len=fr.read(cs);
}
long end=System.currentTimeMillis();
System.out.println("字符流读写:"+(end-start));
fr.close();
fw.flush();
fw.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}