A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

这个是复制图片的代码:
import java.io.*;
class CopyPic{
        public static void main(){
                FileOutputStream fos=null;
                FileIntputStream fis=null;
                try{
                        fos=new FileOutputStream(c:\\2.jpg);
                        fis=new FileIutputStream(c:\\1.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){
                                throw new RuntimeException("读取关闭失败");
                        }
                        try{
                          if(fos!=null)
                          fos.close();
                        }catch(IOException e){
                                throw new RuntimeException("写入关闭失败");
                        }
                }
        }
}

评分

参与人数 1技术分 +1 收起 理由
czwanglei + 1

查看全部评分

1 个回复

倒序浏览
没弄明白你想问什么
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马