- /**
- * 读取流
- *
- * @param inStream
- * @return 字节数组
- * @throws Exception
- */
- public static byte[] readStream(InputStream inStream) throws Exception {
- ByteArrayOutputStream outSteam = new ByteArrayOutputStream();
- byte[] buffer = new byte[1024];
- int len = -1;
- while ((len = inStream.read(buffer)) != -1) {
- outSteam.write(buffer, 0, len);
- }
- outSteam.close();
- inStream.close();
- return outSteam.toByteArray();
- }
java 读取流
最新推荐文章于 2023-05-05 20:49:28 发布
本文介绍了一种使用Java实现的从输入流中读取数据的方法,并将其转换为字节数组的形式。该方法通过创建一个输出流来缓存读取到的数据,直到输入流结束,然后返回完整的字节数组。
3737

被折叠的 条评论
为什么被折叠?



