package test;
import java.io.*;
public class Fuzhi {
public static void main(String[] args) {
cope();
}
public static void cope() {
FileWriter fw = null;
FileReader fr = null;
try {
fw = new FileWriter("f:/dome-cope.txt");
fr = new FileReader("f:/dome.txt");
char[] buf = new char[1024];
System.out.println(new String(buf));
int len = 0;
while ((len = fr.read(buf)) != -1) {
fw.write(buf, 0, len);
}
} catch (IOException e) {
// TODO: handle exception
throw new RuntimeException("duxiecuowu");
} finally {
if (fr != null) {
try {
fr.close();
} catch (IOException e2) {
// TODO: handle exception
}
}
if (fw != null) {
try {
fw.close();
} catch (Exception e2) {
// TODO: handle exception
}
}
}
}
}
总是报错 求解!!! |