【Java】字节流复制图片
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
public class CopyPngDemo {
public static void main(String[] args) throws IOException {
FileInputStream fis = new FileInputStream("D:\\MyProject\\Java\\LearnJava1\\src\\Demo4\\img.png");
FileOutputStream fos = new FileOutputStream("D:\\MyProject\\Java\\LearnJava1\\src\\Demo4\\img2.png");
byte[] bys = new byte[1024];
int len;
while ((len = fis.read(bys)) != -1) {
fos.write(bys);
}
fos.close();
fis.close();
}
}
本文来自博客园,作者:木子欢儿,转载请注明原文链接:https://www.cnblogs.com/HGNET/p/16167238.html