package day04Stream;
import java.io.*;
import java.nio.channels.FileChannel;
import java.nio.file.Paths;
import java.util.Scanner;
/**
* @author yyc
* 运用BufferInputStream实现图片的复制
*/
public class IOExise {
public static void main(String[] args) throws IOException {
String fromPath = "E:\\架设\\2021实训作业\\img\\a.jpg";
String targetPath = "E:\\Mycode\\Basic\\iotest\\bb.jpg";
CopyImg(fromPath,targetPath);
}
public static void CopyImg(String fromPath, String targetPath) throws IOException {
InputStream input = new BufferedInputStream(new FileInputStream(fromPath));
OutputStream output = new BufferedOutputStream(new FileOutputStream(targetPath));
int b;//用来记录读入的数据
while((b = input.read()) != -1){
output.write(b);
}
output.close();
input.close();
}
}
流-BufferInputStream拷贝图片
最新推荐文章于 2022-09-12 12:04:09 发布