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"
Hi Norm,
Considering your membership status and number of posts I would like to have some assistance and help from your side rather than redirecting me to some other forum links.
It would be appreciated if you can share some of your knowledge with beginners like us. Hoping for some help from you.
Don't take it otherwise.
Goldest
Re: Help needed for "java.io.IOException: Not in GZIP format"
The problem is that you have posted this question on several other forums and have NOT informed any of them about the other forums. Known as "Cross posting"
If someone wants to help and takes the time to do some research and then finds that the question was answered on another forum, he'll feel that he has wasted his time.
So when you ask on multiple forums, take the time and be considerate of others and tell them about the other posts to save them duplicate efforts.
Re: Help needed for "java.io.IOException: Not in GZIP format"
I've had no problems reading in a gzip compressed file. Check to make sure that the file isn't corrupted, and is indeed in the gzip file format and doesn't just happen to have the ".tar.gz" file ending.
Re: Help needed for "java.io.IOException: Not in GZIP format"
Got that Norm. Thanks for the explanation. Will keep that in mind henceforth.
Well, coming back to the issue. What I was doing was, I was downloading any tar.gz file from internet and passing it to the GZIPInputStream as an input through FileInputStrem. The issue seems like "How that tar.gz was originally created?".
I am not sure about how tar.gz files get usually created, but may be because of some other/different technique used in the tar.gz creation, the GZIPInputStream was showing the error in readHeader. OR for may be some other weird reasons.
When I manually pass any File(s) and compress it to tar.gz using GZIPOutputStrem, the problem seems to be disappeared.
So for now, the issue is resolved.
Thanks helloworld922 for responding and Norm for suggesting the way, cross posted here
Thanks much,
Goldest