• 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

Not sure if my program is even possible to implement anymore

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!

So I am writing this program that should list the contents of a ZIP file that is in the WEB, without downloading it.

The only way to read anything from it as I understand is with a InputStream, if I don't want to download the file. But in the InputStream, even if I know that the Central Directory is located in the end and I take off the 65k of bytes from the total length of the stream, it will still download the whole ZIP file, even if I tell it to skip() over a certain amount of bytes.

So am I at a dead end here or is there maybe a better solution here?
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are in control of the Web side of things then you could write a service which inspects the contents and sends just the directory. But if you are only in control of the client side then you do need to download the entire file. The thing with streams is that they are a linear collection of data. To get to any part you need to go through all the previous parts. So skip still needs to transfer all the bytes that you want to skip, it just throws them away as you don't need them.
 
Marshal
Posts: 79179
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And welcome to the Ranch
 
Kaido Lind
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for the reply! I was going mad all ready, trying to solve the issue in any way possible...
 
Kaido Lind
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Solved the problem. In case anyone wants to know how to deal with -zip files central directory then you could have a look at this repo i uploaded to GitHub: https://github.com/Veske/Zip_file_reader
reply
    Bookmark Topic Watch Topic
  • New Topic