将一个文本文件中的内容复制到另一个文本文件中:
<span style="font-family:Times New Roman;font-size:24px;">import java.io.*;
public class Test {
public static void main(String[] args) {
FileReader fis=null;
FileWriter fos=null;
try{
fis=new FileReader("D:/Android/Java/CharStream/src/Input.txt");
fos=new FileWriter("D:/Android/Java/CharStream/src/Out.txt");
char [] buffer=new char[1000];
while(true){
int temp=fis.read(buffer,0,buffer.length);
if(temp==-1)
break;
fos.write(buffer,0,temp);
}
}
catch(Exception e){
System.out.println(e);
}
finally{
try{
fis.close();
fos.close();
}
catch(Exception e)
{
System.out.println(e);
}
}
}
}
</span>