第1个回答 推荐于2016-02-10
给你比较简洁的答案:
import java.io.FileReader;
import java.io.FileWriter;
public class TestCopy {
public static void main(String[] args) {
try {
FileReader fr = new FileReader("D:/text.txt");
FileWriter fw = new FileWriter("D:/textCopy.txt");
int b = fr.read();
while (b != -1) {//读取文件,一边输出内容
fw.write(b);
System.out.print((char) b);
b = fr.read();
}
fw.close();
fr.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
好好看下API吧。本回答被提问者采纳