package Day0213;
import java.io.*;
/**
* @author CF
* @version 1.0
* @date 2023/2/13 12:53
*/
public class Test04 {
public static void main(String[] args) throws IOException {
// 创建高效的字节输入流对象
// 在底层会创建一个长度为8192的数组
BufferedInputStream bis = new BufferedInputStream(new FileInputStream("D:\\2022-12-01 112455.jpg"));
// 创建高效的字节输出流
// 在底层会创建一个长度为8192的数组
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("D:\\copy3.jpg"));
// 使用高效流 , 一次读写一个字节
// int by;
// while ((by = bis.read()) != -1) {
// bos.write(by);
// }
byte[] bys = new byte[1024];
int len;// 每次真实读到数据的个数
while ((len = bis.read(bys)) != -1) {
bos.write(bys, 0, len);
}
bis.close();
bos.close();
}
}
缓冲流复制图片文件(更高效)
最新推荐文章于 2024-06-14 15:02:13 发布