原文地址:http://blog.csdn.net/the_star_is_at/article/details/72229096
import java.io.*;
public class copy
{
public static void main(String []args)
{
try{
FileReader a = new FileReader("a.txt");
BufferedReader b = new BufferedReader(a);
FileWriter c = new FileWriter("b.txt");
BufferedWriter d = new BufferedWriter(c);
String s = null;
while((s=b.readLine())!=null)
{
d.write(s);
d.newLine();
}
d.flush();
c.close();
a = new FileReader("b.txt");
b = new BufferedReader(a);
while((s=b.readLine())!=null)
{
System.out.println(s);
}
a.close();
b.close();
}
catch(Exception e)
{
System.out.println(e.toString());
}
}
}