InputStream ticketInstream = httpResponse.getEntity().getContent();
byte[] buffer = new byte[1024];
//每次读取的字符串长度,如果为-1,代表全部读取完毕
int len = 0;
//使用一个输入流从buffer里把数据读取出来
while( (len=inStream.read(buffer)) != -1 ){
//用输出流往buffer里写入数据,中间参数代表从哪个位置开始读,len代表读取的长度
outStream.write(buffer, 0, len);
}
ByteArrayOutputStream outStream = new ByteArrayOutputStream();byte[] data = outStream.toByteArray();// 输出的文件流保存图片至本地 OutputStream out = new FileOutputStream(new File("E:\"+1+".jpg")); out.write(data); out.flush();
最后
以上就是勤奋大山最近收集整理的关于如何将格式为byte[]的图片保存在本地的全部内容,更多相关如何将格式为byte[]内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复