有人能帮我看看这个程序么?读入一个文件到另外一个文件的方法! 本帖最后由 virgo777 于 2012-04-02 14:02:57 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你流关闭的地方错了,应该读完了再写完了再关闭fr和fw。不然你关了就没法写了。 public static void fileput(String filePath) { int a = 0; FileReader fr = null; FileWriter fw = null; try { fr = new FileReader(filePath); fw = new FileWriter("c:/javatest/cool.txt"); while ((a = fr.read()) != -1) { fw.write(a); } } catch (IOException e1) { System.out.println("就是错误!"); } finally { if (fr != null) { try { fr.close(); } catch (IOException e) { e.printStackTrace(); } } if (fw != null) { try { fw.close(); } catch (IOException e) { e.printStackTrace(); } } } } 帮帮忙!哪里错了!怎么读出double类型数据 关于equals方法的重写 请问。高手帮帮忙,关于poi处理ppt的问题,ppt内部有嵌入的EXCEL 有关response问题? java连接Oracle数据库需要怎么设置啊? 线程等待时间sleep(x ms)x ms是指本线程得到运行时积累的ms数还是整个系统度过的ms数? 新手遇难 DataInput如何读取中文文件 多线程下,机器性能太好,导致内存溢出?? 求一个解析json字符串的正则表达式 最近碰到一个难题,关于java 按钮,icon的 请教一个DJ NativeSwing自动关闭打开窗口的问题
不然你关了就没法写了。
public static void fileput(String filePath) {
int a = 0;
FileReader fr = null;
FileWriter fw = null;
try {
fr = new FileReader(filePath);
fw = new FileWriter("c:/javatest/cool.txt");
while ((a = fr.read()) != -1) {
fw.write(a);
}
} catch (IOException e1) {
System.out.println("就是错误!");
} finally {
if (fr != null) {
try {
fr.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (fw != null) {
try {
fw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}