• 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
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

zip file to client

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a zip file in my D: folder.Now i need to send it to my client.I did in the following way.
<code>

fileIn = new FileInputStream("D:/files.zip");

input = new ZipInputStream(fileIn);


buf = new BufferedInputStream(input);

ServletOutputStream servletOut = response.getOutputStream();
response.setContentType("application/zip");
response.addHeader("Content-Disposition", "attachment; filename=myZip");

int readBytes = 0;

while ((readBytes = buf.read()) != -1)
servletOut.write(readBytes);
servletOut.flush();
</code>

Am able to get a file with aname myZip but it doesnot contain any files inside.
Can anyone suggest what can be wrong here.
 
Sheriff
Posts: 67645
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please UseCodeTags.
 
kv ruby
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i simply messed up with the code.

got the solution.ZipInputReader is not needed.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you writing to the client a byte at a time?!
 
reply
    Bookmark Topic Watch Topic
  • New Topic