如何解压缩字节数组中的gzip压缩数据? [英] How to decompress a gzipped data in a byte array?
问题描述
我有一个类,它有一个接收对象作为参数的方法。
此方法通过RMI调用。
I have a class which has a method that is receiving an object as a parameter. This method is invoked via RMI.
public RMIClass extends Serializable {
public RMIMethod(MyFile file){
// do stuff
}
}
MyFile有一个名为body的属性,它是一个字节数组。
MyFile has a property called "body", which is a byte array.
public final class MyFile implements Serializable {
private byte[] body = new byte[0];
//....
public byte[] getBody() {
return body;
}
//....
}
这个property保存由另一个应用程序解析的文件的gzip压缩数据。
This property holds the gzipped data of a file that was parsed by another application.
我需要解压缩此字节数组,然后才能执行进一步的操作。
I need to decompress this byte array before performing further actions with it.
我看到的解压缩gzip压缩数据的所有例子都假设我想把它写入磁盘并创建一个物理文件,我不这样做。
All the examples I see of decompressing gzipped data assume that I want to write it to the disk and create a physical file, which I do not.
我该怎么做?
提前致谢。
推荐答案
用 ByteArrayInputStream 并将其输入 GZipInputStream
这篇关于如何解压缩字节数组中的gzip压缩数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!