Solved

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

Posted on 2004-08-19
2
212 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Article by: Justin
In light of the WannaCry ransomware attack that affected millions of Windows machines, you might wonder if your Mac needs protecting. Yes, it does and here is how to do it.
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

690 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