我使用PHP的gzcompress压缩String()函数:Java的PHP的gzuncompress函数?
http://us2.php.net/manual/en/function.gzcompress.php
我想借此从PHP压缩函数的输出,并解压缩在Java中的字符串。任何人都可以把我送到正确的道路上吗?
非常感谢!
我使用PHP的gzcompress压缩String()函数:Java的PHP的gzuncompress函数?
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
}
这是很老,但它可能只是包含正确的信息,让你开始:http://java.sun.com/developer/technicalArticles/Programming/compression/
把数据放到一个ByteArrayInputStream
,那么你应该能够将其与GZipInputStream
解码。
要从字符串中获取字节,请尝试getBytes("ISO-8859-1")
。这种编码不会改变传入的字节。