主题:j2se 文件流问题
import java.io.*;
public class TestFileReader{
public static void main(String args[]){
int c = 0;
FileReader fr = null;
FileWriter fw = null;
try{ fr = new FileReader("D://在家的日子.txt");
fw = new FileWriter("D://java//在家的日子.txt");
}catch(IOException e){
System.out.println("没有找到文件");
System.exit(-1);
}
try{ while((c=fr.read())!=-1){
fw.write(c);
}
System.out.println("文件复制完成");
}catch(IOException ee){
System.out.print("Error");
}
}
}
以上是我的代码 我希望通过文件流复制一个名为“在家的日子.txt”的文档,运行成功且无报错,但是复制出来的文档中没有任何内容,我尝试打印c ,没有任何问题,不知道我的问题出在哪里,麻烦大家帮我看看,谢谢
public class TestFileReader{
public static void main(String args[]){
int c = 0;
FileReader fr = null;
FileWriter fw = null;
try{ fr = new FileReader("D://在家的日子.txt");
fw = new FileWriter("D://java//在家的日子.txt");
}catch(IOException e){
System.out.println("没有找到文件");
System.exit(-1);
}
try{ while((c=fr.read())!=-1){
fw.write(c);
}
System.out.println("文件复制完成");
}catch(IOException ee){
System.out.print("Error");
}
}
}
以上是我的代码 我希望通过文件流复制一个名为“在家的日子.txt”的文档,运行成功且无报错,但是复制出来的文档中没有任何内容,我尝试打印c ,没有任何问题,不知道我的问题出在哪里,麻烦大家帮我看看,谢谢