Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Servlets
Search Coderanch
Advance search
Google search
Register / Login
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
Forum:
Servlets
zip file to client
kv ruby
Ranch Hand
Posts: 38
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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.
Regards, ruby kv
rubyshiv.blogspot.com
Bear Bibeault
Sheriff
Posts: 67645
173
I like...
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Please
UseCodeTags
.
[
Asking smart questions
] [
About Bear
] [
Books by Bear
]
kv ruby
Ranch Hand
Posts: 38
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
i simply messed up with the code.
got the solution.ZipInputReader is not needed.
Regards, ruby kv
rubyshiv.blogspot.com
David Newton
Author
Posts: 12617
I like...
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Are you writing to the client a byte at a time?!
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
how to cath and use actual date from ANT?
Excluding directory when zipping contents
XML data extraction code performance....
Update the character on file writing.
open pdf inside browser
More...