因此,我的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);
}
Run Code Online (Sandbox Code Playgroud)
'inputData'是一个包含放气数据的String.
问题是:.read方法抛出异常:
java.util.zip.ZipException:标头检查不正确
关于这个主题的其他网站只是将我重定向到Inflater类的文档,但显然我不知道如何使用它来与PHP兼容.