本帖最后由 zl78365336 于 2013-11-16 20:34 编辑
package test;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
public class BufferCopy {
public static void main(String[] args) {
BufferedReader bufr = null;
BufferedWriter bufw = null;
try{
bufr = new BufferedReader(new FileReader("MathTest.java"));
bufw = new BufferedWriter(new FileWriter("Copy.txt"));
String line = null;
while((line=bufr.readLine())!=null){
bufw.write(line);
bufw.newLine();
bufw.flush();
}
}catch(IOException e){
throw new RuntimeException("读写失败···"+e.toString());
}finally{
try{
if(bufr!=null)
bufr.close();
}catch(IOException e){
throw new RuntimeException("读取流关闭失败···"+e.toString());
}
try{
if(bufw!=null)
bufw.close();
}catch(IOException e){
throw new RuntimeException("读入流关闭失败···"+e.toString());
}
}
}
}
----------------------------------------------------
Exception in thread "main" java.lang.RuntimeException: 读写失败···java.io.FileNotFoundException: MathTest.java (系统找不到指定的文件。)
----------------------------------------------------
为什么显示读失败?
我的都是默认相对路径啊!
请教各位师兄!怎么解决。
|