日期:2014-05-20 浏览次数:20881 次
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( "写关闭失败");
}
}
}
}