1

So at the end of a ZIP file, like the last 64K there is a Central Directory from which you could see what the ZIP file it self contains.

Now I have loaded my ZIP file into a ZipInputStream and before that I have declared a long variable that is the length of the ZIP file - the 64k.

So I want to skip as many bytes and the long variable states, and only start reading info after that. But I dont really understand how the .skip() method works for ZipInputStream.

After using it, the .getNextEntry() method will still start from the beginning and .read(byte[64 * 1024]) will tell me that it's the end of the stream which it should not be?

So what is this skip() method actually doing and how can I get my Central Directory?

Veske
  • 547
  • 1
  • 4
  • 15

1 Answers1

2

As far as I can see, you are mixing two things here.

Either read your data as a plain InputStream, go to the position you want and start reading and parsing the plain data yourself.

Or use the ZipInputStream API and iterate through the ZipEntries. The ZipInputStream is an abstraction on top of the raw stream that handles reading the central directory and uncompressing the compressed bytes transparently. So you cannot get access to the raw directory using the ZipInputStream.

For more information, see also

Community
  • 1
  • 1
Stefan Winkler
  • 3,871
  • 1
  • 18
  • 35
  • 1
    ZipInputStream has skip implemented, but getNextEntry does not read from where you skipped . – alwynd Oct 24 '17 at 11:17