Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Downloading a zip file using Apache Commons HttpClient

 
Chase Bonham
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a situ where I'm using Apache Commons HttpClient and Commons IO to download a ZIP file from a url.



For some reason the downloaded zip file is always couple of 1000 bytes less thereby rendering the file useless.

What am I missing?

[ September 12, 2006: Message edited by: Chase Bonham ]

[ September 12, 2006: Message edited by: Chase Bonham ]

[ September 12, 2006: Message edited by: Chase Bonham ]
[ September 12, 2006: Message edited by: Chase Bonham ]
 
Joe Ess
Bartender
Posts: 9362
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Invoke flush() and close() on your output stream. Buffered streams read large amounts of data into memory so they incur fewer external reads on slow devices. Of course, that means that data may be lingering in the buffer when your program ends and never gets written.
BTW, IOUtils buffers data internally so there's no need for additional buffering.
 
Chase Bonham
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That fixed it. Thanks
 
Hug your destiny! And hug this tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!