ByteArrayInputStream&ByteArrayOutputStream

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;

public class ByteArrayStreamDemo {

    public static void main(String[] args) {
        
        
        //用io的读写思想操作数组
        //1.确定源
        ByteArrayInputStream bis = new ByteArrayInputStream("abcde".getBytes());//这个数据 可以来自于文件
        //2.确定目的
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        
        int by = 0;
        
        while((by=bis.read())!=-1){
            bos.write(by);
        }
        
        System.out.println(bos.toString());
        
    }

}
原文地址:https://www.cnblogs.com/qjlbky/p/5926016.html