日期:2014-05-20  浏览次数:20784 次

请高手帮我看下代码哪里错了(编译通过,运行错误)
本帖最后由 cnaaa8 于 2013-01-16 22:21:40 编辑


import java.io.*;
public class copy {
public static void main(String[] args){
// TODO 自动生成的方法存根
copy1();
}


public static void copy1(){
BufferedInputStream bufrs=null;
BufferedOutputStream bufws=null;
try {
bufrs=new BufferedInputStream(new FileInputStream("1.jpg"));
bufws=new BufferedOutputStream(new FileOutputStream("2.jpg"));
int len=0;
while((len=bufrs.read())!=-1){
bufws.write(len);
}
} catch (IOException e) {
throw new RuntimeException( "读写失败");//这个地方提示错误,错误代码如下,应该如何改呢
/*
Exception in thread "main" java.lang.RuntimeException: 读写失败

*/
}finally{
try {
if(bufrs!=null)
bufrs.close();
} catch (Exception e2) {
throw new RuntimeException( "读关闭失败");
}



try {
if(bufws!=null)
bufws.close();
} catch (Exception e3) {
throw new RuntimeException( "写关闭失败");
}
}
}

}

------解决方案--------------------
路径问题吧 认真检查下