Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

GZip Version Problems

807603Jan 30 2008 — edited Jan 30 2008
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();
			}
		}
	}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 27 2008
Added on Jan 30 2008
5 comments
377 views