【发布时间】:2012-07-09 02:31:33
【问题描述】:
所以,我的 Java 应用程序接收了一些使用 PHP 的 gzdeflate() 生成的数据。 现在我正在尝试用 Java 扩充这些数据。这是我到目前为止所得到的:
InflaterInputStream inflInstream = new InflaterInputStream(new ByteArrayInputStream(inputData.getBytes() ), new Inflater());
byte bytes[] = new byte[1024];
while (true) {
int length = inflInstream.read(bytes, 0, 1024);
if (length == -1) break;
System.out.write(bytes, 0, length);
}
'inputData' 是一个包含压缩数据的字符串。
问题是:.read方法抛出异常:
java.util.zip.ZipException:标头检查不正确
关于这个主题的其他网站只会将我重定向到 Inflater 类的文档,但显然我不知道如何使用它来与 PHP 兼容。
【问题讨论】: