Solved

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

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This article describes my battle tested process for setting up delegation. I use this process anywhere that I need to setup delegation. In the article I will show how it applies to Active Directory
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
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…

792 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