java字节流——实现文件的拷贝,将一张图片复制到另一个路径下
程序员文章站
2022-07-11 11:41:33
...
package com.oracle.core;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
public class CopyImage
{
public static void main(String[] args) throws IOException
{
InputStream in=new FileInputStream("D:\\hello.jpg");
byte[] b=new byte[in.available()];
in.read(b);
OutputStream out=new FileOutputStream("D:\\hello1.jpg");
out.write(b);
in.close();
out.close();
}
}