我正在使用PHP的gzcompress()函数压缩字符串:

http://us2.php.net/manual/en/function.gzcompress.php

我想从PHP压缩函数获取输出并在Java中解压缩字符串。谁能送我正确的道路?

非常感谢!

最佳答案

看一下GZIPInputStream

GZIPInputStream gzipInputStream = new GZIPInputStream(new FileInputStream(inFilename));
byte[] buf = new byte[1024];
int len;
while ((len = gzipInputStream.read(buf)) > 0) {
    // buf contains uncompressed data
}

07-27 15:39