• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Error Extracting a file from a TAR.GZ archive

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I need to extract a file from a tar.gz archive, there is nothing else in the archive except for this file.
To do this I am using http://www.trustice.com/java/tar/

I was able to open the archive but hit a brick wall trying to extract the file:

The the second line throws an exception:
java.util.zip.ZipException: invalid bit length repeat

Is something wrong with the archive or with my code?
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Jason", please check your private messages for an important administrative matter.
 
author
Posts: 9050
21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
intermediate...
 
Author
Posts: 836
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As with all of these types of problems when an error occurs, try to do fewer things at once. So in your case:
  • Firstly, can you extract the archive in an external program which you know works? If not, the file is corrupt and your program is probably fine! If it opens okay, continue to investigate...
  • Write a test program which takes the .tar.gz as input and outputs the .tar file (i.e. uses GZIPInputStream only). Then check this .tar using an external reader to see if it's valid. If so, then all is good so far. If not, something isn't working with the Java GZip extraction.
  • Finally test the entire program you have above. If it's still causing a problem, the error must lie in TarInputStream (either in its methods reading from the GZIPInputStream, or decoding functionality).
  • That should help you narrow down where the problem is occurring, and hence focus on where to implement a fix. Also check the docs for TarInputStream to ensure there are no other initialisation methods you're supposed to invoke before calling getNextEntry(). Also check the bug database for your library, and Google for people with similar problems. If you've tried all that and are still stuck, post back.
     
    reply
      Bookmark Topic Watch Topic
    • New Topic