本帖最后由 pthuakai 于 2013-5-8 09:15 编辑
package day19;
import java.io.*;
public class copypictureTest {
public static void main(String[] args) {
FileInputStream fis=null;
FileOutputStream fos=null;
try{
fis=new FileInputStream("1.jpeg");
fos=new FileOutputStream("copypicture.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("fis fail");
}
try{
if(fos!=null)
fos.close();
}catch(IOException e)
{
throw new RuntimeException("fos fail");
}
}
}
}
为什么老是提示 throw new RuntimeException("复制文件失败");这行出错?是不是必须是bmp格式图片才行?
|