麻烦大家帮忙看下这是什么情况
import *;class CopyPicture
{
public static void main(String[] args)
{
FileOutputStream fos = null;
FileInputStream fis = null;
try
{
fos = new FileOutputStream("c:\\1.jpg");
fis = new FileInputStream("c:\\2.jpg");
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)
{
System.out.println(e.toString());
}
try
{
if(fos != null)
fos.close();
}
catch(IOException e)
{
System.out.println(e.toString());
}
}
}
}
调用的图片是在指定的位置的,但是运行后会出现 Exception in thread "main " java.lang.RuntimeException :文件复制失败!
麻烦帮忙指点一下,多谢大家了