首页 > 技术文章 > InputStream流转字节数组

dreammyone 2017-08-23 16:05 原文

  //将流(inputs)转成字节数组
            ByteArrayOutputStream outStream = new ByteArrayOutputStream();
            byte[] buff = new byte[100]; //buff用于存放循环读取的临时数据
            int rc = 0;
            while ((rc = inputIs.read(buff, 0, 100)) > 0) {
                outStream.write(buff, 0, rc);
            }
            //合并之后的字节数组
            byte[] in_merge = outStream.toByteArray();

  

推荐阅读