• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Downloading a zip file using Apache Commons HttpClient

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That fixed it. Thanks
 
reply
    Bookmark Topic Watch Topic
  • New Topic