首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

byte[] 跟 InputStream 相互转化

2012-11-09 
byte[] 和 InputStream 相互转化1. byte[] - InputStream????? byte[] b ?xxx??????InputStream is n

byte[] 和 InputStream 相互转化

1. byte[] -> InputStream

????? byte[] b =?xxx;

??????InputStream is = new ByteArrayInputStream(b);

?

2. InputStream -> byte[]

?? InputStream is = xxx;
???ByteArrayOutputStream bytestream = new ByteArrayOutputStream();
???int ch;
???while ((ch = is.read()) != -1) {
????bytestream.write(ch);
???}
???byte[] b = bytestream.toByteArray();
???bytestream.close();

热点排行