public class INOUTPUT {
    @Test
    public void kkbb(){
        String str1=\"C:\\\\Users\\\\Administrator\\\\Desktop\\\\1.pic_hd.jpg\";
        String str2=\"C:\\\\Users\\\\Administrator\\\\Desktop\\\\kobe.jpg\";
        Copythat(str1,str2);
    }
   
    public void Copythat(String str1,String str2){
        File kb = new File(str1);
        File kb28 = new File(str2);
        FileOutputStream fos=null;
        FileInputStream fis=null;
        try{
            fis = new FileInputStream(kb);
            fos = new FileOutputStream(kb28);
            //实现文件复制
            byte[] b = new byte[5];
            int length;
            while ((length = fis.read(b)) != -1) {
                fos.write(b,0,length);
            }
        }catch(Exception e){
            e.printStackTrace();
        }finally {
                if(fis!=null){
                    try{
                        fis.close();
                    }catch (IOException e){
                        e.printStackTrace();
                    }
                }
            if(fos!=null){
                try{
                    fos.close();
                }catch (IOException e){
                    e.printStackTrace();
                }
            }
        }
    }
    }

\"\"

收藏 打印