public class test{
public static void main(String[] args){
//事先在d盘创建test.txt
File f = new File("d:\\test.txt");
File f1 = new File("e:\\test.txt");
//创建文件流
FileReader reader = new FileReader(f)
FileWriter writer = new FileWriter(f1);
char[] buff = new char[512];//缓存
int len =0;//记录字符长度
while((len=reader.read(buff))!=-1){
String str = new String(buff,0,len);
writer.write(str);//写入f1
writer.flush();//刷新缓存区
}
//关闭资源
reader.close();
writer.close();
}
}