Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: Help needed for "java.io.IOException: Not in GZIP format"

  1. #1
    Member goldest's Avatar
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    63
    Thanks
    1
    Thanked 12 Times in 10 Posts

    Unhappy 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,


    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,

    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


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Help needed for "java.io.IOException: Not in GZIP format"


  3. #3
    Member goldest's Avatar
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    63
    Thanks
    1
    Thanked 12 Times in 10 Posts

    Default 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

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default 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.

  5. #5
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,895
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default 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.

  6. #6
    Member goldest's Avatar
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    63
    Thanks
    1
    Thanked 12 Times in 10 Posts

    Thumbs up 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

Similar Threads

  1. Java says:"Hello World". I say:"It works!"
    By Davidovic in forum Member Introductions
    Replies: 4
    Last Post: June 29th, 2010, 07:13 AM
  2. "java.lang.NoSuchMethodError: main" and "fatal exception occured."
    By joachim89 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: January 10th, 2010, 08:35 AM
  3. Replies: 1
    Last Post: October 25th, 2009, 11:54 AM
  4. HELP "code needed"
    By Dave in forum File I/O & Other I/O Streams
    Replies: 14
    Last Post: August 26th, 2009, 11:06 AM
  5. [SOLVED] "GridLayout" problem in Java program
    By antitru5t in forum AWT / Java Swing
    Replies: 3
    Last Post: April 16th, 2009, 10:26 AM