import java.io.*;
class CopyPic
{
public static void main(String[] args)
{
FileInputStream fis=null;
FileOutputStream fos=null;
try
{
fis=new FileInputStream("c:\\1.jpeg");
fos=new FileOutputStream("c:\\2.jpeg");
byte[] buf=new byte[1024];
int len=0;
while((len=fis.read(buf))!=-1)
{
fos.write(buf,0,len);
}
}
catch (IOException e)
{
throw new RuntimeException("复制图片失败");
}
finally
{
try
{
if(fis!=null)
fis.close();
}
catch (IOException e)
{
throw new RuntimeException("提取图片失败");
}
try
{
if(fos!=null)
fos.close();
}
catch (IOException e)
{
throw new RuntimeException("写入图片失败");
}
}
}
}
运行时抛出异常
Exception in thread "main" java.lang.RuntimeException: 复制图片失败
at CopyPic.main(CopyPic.java:25)
什么问题? 用dos调试的 |