import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
public class fanxing {
public static void main(String args[]) throws IOException {
method_one();
method_two();
}
public static void method_one() throws IOException {
FileReader fr = new FileReader("读我.txt");
FileWriter fw = new FileWriter("zhpu_one.txt");
int len = 0;
while ((len = fr.read()) != -1) {
fw.write((char) len);
}
fw.close();
fr.close();
}
public static void method_two() throws IOException {
FileReader fr = new FileReader("读我.txt");
FileWriter fw = new FileWriter("zhpu_two.txt");
char arr[] = new char[1024];
int len = 0;
while ((len = fr.read(arr)) != -1) {
fw.write(arr, 0, len);
fw.flush();
}
fw.close();
fr.close();
}
}
Java_文件copy的两种方式
最新推荐文章于 2024-06-07 00:50:21 发布