package other;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class ByteArrayStream {
public static void main(String[] args) throws IOException {
//数据源。
ByteArrayInputStream bis = new ByteArrayInputStream("abc".getBytes());
//数据目的
ByteArrayOutputStream bos = new ByteArrayOutputStream();
int by=0;
while((by=bis.read())!=-1){
bos.write(by);
//写入到文件
bos.writeTo(new FileOutputStream("a.txt"));
}
System.out.println(bos.size());
}
}
操作字节数组
最新推荐文章于 2023-12-27 17:32:06 发布