• Post Reply Bookmark Topic Watch Topic
  • New Topic

Downloading a zip file using Apache Commons HttpClient  RSS feed

 
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: 9429
12
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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!