Hello Everyone,
I have the need to decompress an array of bytes that are given to me in gzip format. The problem that I am facing is that I beleive that the version of gzip that the bytes are compressed with, is different than the version of gzip that is built into the java API. Every time I try to unzip the bytes using GZIPInputStream, I get the error "Not in gzip format." Is there any way I can decompress gzip files compressed with an older version of gzip? Does anyone know the version of Gzip java uses?
Thanks for all the help
- Jon
Here is my decompress code:
static byte[] Decompress(byte[] buffer) throws IOException
{
ByteArrayInputStream bin = new ByteArrayInputStream(buffer);
GZIPInputStream zip = null;
try
{
zip = new GZIPInputStream(bin);
ByteArrayOutputStream bout = new ByteArrayOutputStream();
while(true)
{
int b = zip.read();
if(b == -1)
{
break;
}
bout.write(b);
}
return bout.toByteArray();
}
finally
{
if (zip != null)
{
zip.close();
}
}
}