Help needed for "java.io.IOException: Not in GZIP format"
Hi Everyone,
I am facing some issues with GZIPInputStream. I am trying to connect a FileInputStream thru it, but some weird exception is coming my way... Posting the code below,
Code:
import java.io.FileInputStream;
import java.util.zip.GZIPInputStream;
public class GZipTester {
public static void main(String args[])
{
try
{
String file = "C://Testing.tar.gz";
GZIPInputStream gzip = new GZIPInputStream(new FileInputStream(file));
System.out.println("Success...");
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
The tar.gz file exists at it's place, so no issue with that. When I try to run this, I get a big exception,
Code:
java.io.IOException: Not in GZIP format
at java.util.zip.GZIPInputStream.readHeader(GZIPInputStream.java:131)
at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:58)
at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:68)
at GZipTester.main(GZipTester.java:10)
Can someone please help me out in this? I have spent almost all my day digging into this issue. But no success.
Any help would be appreciated!
Thanks much,
Goldest
Re: Help needed for "java.io.IOException: Not in GZIP format"
Re: Help needed for "java.io.IOException: Not in GZIP format"
You can tell from the stack trace that the GZIP class is attempting to read the header, so it doesn't look like there is anything wrong with your code.
Are you certain the file is a valid file? How did you create it?
Re: Help needed for "java.io.IOException: Not in GZIP format"
Thanks themoffster for responding.
Yes the file is a valid file which has been downloaded from internet. just to make you more clear that, it's not just this particular file, I have tried using the same code for other tar.gz files as well. But it just doesn't get pass the
Code:
GZIPInputStream gzip = new GZIPInputStream(new FileInputStream(file));
I am not at all sure what can be done to resolve this.
Any inputs from you would be appreciated.
Goldest
Re: Help needed for "java.io.IOException: Not in GZIP format"
Quote:
I have tried using the same code for other tar.gz files as well.
GZIPInputStream is for decompressing zip files not tar.gz files. If you want to work with tar.gz files you will need to use a third party package such as this one.
I've not used this package so can't actually recommend it - I just found it after a quick search.
Re: Help needed for "java.io.IOException: Not in GZIP format"
Thanks for responding guys...
It eventually turned out to be the issue with the tar.gz file.
See details cross posted here
Thanks much,
Goldest