标签:http col 汉字 stat img width final sources rgba
package com.model.io.copy; import java.io.*; /** * @Description:测试类 * @Author: 张紫韩 * @Crete 2021/6/18 20:50 * BufferedInputStream和BufferedOutputStream字节处理流 * 既可以处理二进制文件有可以处理文本文件,但是有可能会出现乱码问题 * 一个字母是一个字节,一个汉字是三个字节 * */ public class CopyDemo03 { public static void main(String[] args) throws IOException { String fileFrom="D:\\qq\\IDEA\\IdeaProjects\\java_mianshi_test\\mianshi_io\\src\\main\\resources\\a.jpg"; String fileTo="D:\\qq\\IDEA\\IdeaProjects\\java_mianshi_test\\mianshi_io\\src\\main\\resources\\File\\aa.jpg"; BufferedInputStream bufferedInputStream=null; BufferedOutputStream bufferedOutputStream=null; byte[] buff = new byte[1024]; int readCount=0; try { bufferedInputStream = new BufferedInputStream(new FileInputStream(fileFrom)); bufferedOutputStream=new BufferedOutputStream(new FileOutputStream(fileTo,true)); //readLine返回null代表读取完成,reed返回-1代表读取完 while((readCount=bufferedInputStream.read(buff))!=-1){ bufferedOutputStream.write(buff,0,readCount); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); }finally { if (bufferedInputStream!=null){ bufferedInputStream.close(); } if (bufferedOutputStream!=null){ bufferedOutputStream.close(); } System.out.println("文件拷贝完成"); } } }
java--IO--BufferedInputStream和BufferedOutputStream
标签:http col 汉字 stat img width final sources rgba
原文地址:https://www.cnblogs.com/zzhAylm/p/14901178.html