如何将整数数组转换为InputStream?
我想将java中的整数数组转换为输入流,之后我想使用LZMA库解压缩字节流。
int [] header = new int[copy.length];
edu.coeia.Compression.LZMA.Decoder decoder = new edu.coeia.Compression.LZMA.Decoder();
ByteArrayInputStream bStream = new ByteArrayInputStream(bheader);
bStream.coder(// InputSream of bytes);
I would like to convert an integer array in java, to an Inputstream, after that I would like to use the stream of bytes to be decompressed using LZMA library.
int [] header = new int[copy.length];
edu.coeia.Compression.LZMA.Decoder decoder = new edu.coeia.Compression.LZMA.Decoder();
ByteArrayInputStream bStream = new ByteArrayInputStream(bheader);
bStream.coder(// InputSream of bytes);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要做的是将整数数组转换为等效的字节数组,然后使用 ByteArrayInputStream(byte[]) 构造函数创建输入流。最后,使用您已有的代码对流进行解码。
第一步(转换)可能是您遇到困难的一步,但代码取决于字节在整数数组中的表示方式。
What you need to do is convert the array of integers into an equivalent array of bytes, and then use the
ByteArrayInputStream(byte[])
constructor to create the input stream. Finally, decode the stream using the code that you already have.The first step (conversion) is probably the one that you are having difficulty with, but the code depends on how the bytes are represented in the integer array.