- 目的:内存 比如从流中获取字符串
- byte[] b = new byte[1024];
- int len = 0;
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- while((len = is.read(b)) != -1){
- //把读到的字节先写入字节数组输出流中存起来
- bos.write(b, 0, len);
- }
- // 将字节流装换成字节数组并构造字符串
- String html = new String(baos.toByteArray()");
复制代码 |
|