byte[]和InputStream的相互转
来源:互联网 发布:淘宝图库网站 编辑:程序博客网 时间:2024/05/16 15:55
byte[]和InputStream的相互转换如下:
1:byte[]转换为InputStream流
InputStream sbs = new ByteArrayInputStream(byte[] buf);
2:InputStream转换为byte[]数组
ByteArrayOutputStream swapStream = new ByteArrayOutputStream();
byte[] buff = new byte[100]; //buff用于存放循环读取的临时数据
int rc = 0;
while ((rc = inStream.read(buff, 0, 100)) > 0) {
swapStream.write(buff, 0, rc);
}
byte[] in_b = swapStream.toByteArray(); //in_b为转换之后的结果
1:byte[]转换为InputStream流
InputStream sbs = new ByteArrayInputStream(byte[] buf);
2:InputStream转换为byte[]数组
ByteArrayOutputStream swapStream = new ByteArrayOutputStream();
byte[] buff = new byte[100]; //buff用于存放循环读取的临时数据
int rc = 0;
while ((rc = inStream.read(buff, 0, 100)) > 0) {
swapStream.write(buff, 0, rc);
}
byte[] in_b = swapStream.toByteArray(); //in_b为转换之后的结果
- byte[]和InputStream的相互转
- byte[]和InputStream的相互转换
- byte[]和InputStream的相互转换
- byte[]和InputStream的相互转换
- byte[]和InputStream的相互转换
- byte[]和InputStream的相互转换
- byte[]和InputStream的相互转换
- byte[]和InputStream的相互转换
- byte[]和InputStream的相互转换
- byte[]和InputStream的相互转换
- byte[]和InputStream的相互转换
- byte[]和InputStream的相互转换
- byte[]和InputStream的相互转换
- byte[]和InputStream的相互转换
- inputstream和byte[]相互转换
- 唯爱小粽子:JAVA中String和byte[]和InputStream之间的相互转换
- 【转载】java输入流转为文件 InputStreamToFile 以及 byte[]和InputStream的相互转换
- java.sql.Blob、byte[]、InputStream之间的相互转换
- proc源码解析(二)--proc数据结构
- ubuntu环境下反编译android apk
- Openstack中Scheduler脚本启动流程和调度流程分析之三
- 设置表格的背景颜色和字体颜色
- Android RadioGroup和RadioButton案例及详解
- byte[]和InputStream的相互转
- sql server 2005数据库中格式化信息并除去空白行
- oracle基本操作符/运算符/操作语言...
- android 图片压缩,可压缩至任意大小(高和宽)
- Unity3D Shader官方教程翻译(四)----Shader语法:SubShader
- qt开发中遇到的问题整理
- vc workspace不能显示类视图/工程文件视图/资源视图
- sys_connect_by_path
- proc源码解析(三)--proc初始化