Solved

Problem with uploading ZIP files..........through servlet using a java client...

Posted on 2004-08-19
2
205 Views
Last Modified: 2010-05-18
hi

i am trying to upload a Zip file from a client program through a Servlet. I am able to upload but the files are correpted. I checked the size of the uploaded file. its same as the orginal file.. i dont know what's the problem..  following is the code in my servlet that reads the file and saves

       BufferedReader buffRead = new BufferedReader(new InputStreamReader(InStream));
       DataOutputStream dos = new DataOutputStream(new FileOutputStream(sFileName));
       int i;
       while ((i = buffRead.read())!=-1)
       {   dos.write(i);
       }        
       buffRead.close();
       dos.close();

Any suggessions pls.. and one more thing if I try this for text files then its uploading fine...

thanks in advance
0
Comment
Question by:ekartha
  • 2
2 Comments
 
LVL 35

Accepted Solution

by:
TimYates earned 125 total points
ID: 11838677
Don't read it with a Reader

Readers are for text files :-/

Change "BufferedReader" to "BufferedInputStream", like:

       BufferedInputStream buffRead = new BufferedInputStream( InStream );

(and make sure you close them in a finally block)

Tim
0
 
LVL 35

Expert Comment

by:TimYates
ID: 11839563
Did it work?  Cool :-)

Good luck with it!!!

Tim
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Exception creating bean of class 5 181
attribute vs parameter and setter vs add method 17 86
Coldfusion 10 - JSP File Not Found - 404 Error 5 92
withoutString  challenge 40 198
When we purchase storage, we typically are advertised storage of 500GB, 1TB, 2TB and so on. However, when you actually install it into your computer, your 500GB HDD will actually show up as 465GB. Why? It has to do with the way people and computers…
Read about the ways of improving workplace communication.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question