Solved

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

Posted on 2004-08-19
2
199 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

HOW TO: Upload an ISO image to a VMware datastore for use with VMware vSphere Hypervisor 6.5 (ESXi 6.5) using the vSphere Host Client, and checking its MD5 checksum signature is correct.  It's a good idea to compare checksums, because many installat…
Find out what Office 365 Transport Rules are, how they work and their limitations managing Office 365 signatures.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

707 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now