CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 2009
    Posts
    8

    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,


    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

  2. #2
    Join Date
    Jun 1999
    Location
    Eastern Florida
    Posts
    3,877

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

    Norm

  3. #3
    Join Date
    Feb 2003
    Location
    Sunny Glasgow!
    Posts
    258

    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?

  4. #4
    Join Date
    Oct 2009
    Posts
    8

    Unhappy 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
    Last edited by goldest; August 8th, 2010 at 03:14 PM.

  5. #5
    Join Date
    May 2006
    Location
    UK
    Posts
    4,473

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

    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.
    Posting code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java Code

  6. #6
    Join Date
    Oct 2009
    Posts
    8

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured