如何解压缩字节数组中的 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;
}
//....
}
此属性保存由另一个应用程序解析的文件的 gzipped 数据.
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.
我看到的所有解压 gzipped 数据的示例都假设我想将其写入磁盘并创建一个物理文件,而我不想这样做.
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屋!