Results 1 to 7 of 7
  1. #1
    goldest's Avatar
    goldest is offline Senior Member
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    469
    Rep Power
    5

    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,


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

    Java 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
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    How did you create that zip file, by renaming an excising? Seems to me that file format is corrupted.

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,421
    Rep Power
    25

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  5. #5
    goldest's Avatar
    goldest is offline Senior Member
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    469
    Rep Power
    5

    Unhappy

    Hi Eranga,

    Thanks for your response on this.

    The file that I am using is a proper tar.gz file which has been downloaded from internet. The file is working fine. By using the WinRAR or any other extracting tool, the file gets extracted correctly and even the contents can be seen properly.

    There is something wrong with the "readHeader" of GZIPInputStream as shown in the stack trace. I am not sure how to resolve this.

    Any help from you will be nice.

    Goldest

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,421
    Rep Power
    25

    Default

    Why do you assume that the file you have is a GZIPOutput file?

    There is something wrong with the "readHeader" of GZIPInputStream as shown in the stack trace
    Change the input to your test program to any text file and see if you get the same trace.

    Rewrite your simple program to use the GZIPOutputStream to write a String out to a file and then have your current code read that same file in and display it. That will work.

    Then look at the file produced and see what utilities can open it and show its contents.

  7. #7
    goldest's Avatar
    goldest is offline Senior Member
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    469
    Rep Power
    5

    Thumbs up Solved

    Thanks Norm! That's what was actually happening.

    More details cross posted here

    Thanks much,
    Goldest

Similar Threads

  1. Replies: 23
    Last Post: 04-18-2010, 09:35 PM
  2. Java, Military Format using "/" and "%" Operator!!
    By sk8rsam77 in forum New To Java
    Replies: 11
    Last Post: 02-26-2010, 03:03 AM
  3. Replies: 0
    Last Post: 04-02-2009, 07:02 PM
  4. Replies: 1
    Last Post: 10-20-2008, 07:35 AM
  5. Struts 1.x <bean:write format="0.00%"> help?
    By prabhurangan in forum Web Frameworks
    Replies: 0
    Last Post: 07-02-2008, 12:59 PM

Posting Permissions

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