通过字节流复制粘贴图片

来源:互联网 发布:重庆交通干部网络学校 编辑:程序博客网 时间:2024/05/01 00:14
package homework;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class CopyPhoto {
    public static void main(String[] args) {
        
    FileInputStream fis;
    FileOutputStream fos;
    byte[] buffer = new byte[1024];
    int ll;
    try {
        fis = new FileInputStream("/Users/xalo/Desktop/a.gif");
        fos = new FileOutputStream("/Users/xalo/Desktop/a1.gif");
        while ((ll = fis.read(buffer)) > 0) {
            fos.write(buffer, 0, ll);
        }
        fis.close();
        fos.close();
    } catch (FileNotFoundException e) {
    
        e.printStackTrace();
    } catch (IOException e) {
        
        e.printStackTrace();
    }
    }
}


原创粉丝点击