Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Download of Zip file not working.

807603Nov 22 2006 — edited Jan 10 2007
I am trying to download a zip file using JAVA IO streams. The downloaded zip file doesnt work with Winzip version 9 or later. Its giving an error "start of central directory not found;zip file corrupt". But the same zip file is working fine with earlier versions of Winzip.

Here is the code I have used.

try {
file = new File(sourcePath + fileName);
}
catch (Exception err) {
log("File : " + fileName + " not found. Ignoring this file"); }
fileinputstream = new FileInputStream(file);
byte[] rgb = new byte[1024];
int n;

BufferedInputStream inputStream = new BufferedInputStream(fileinputstream);
try{
while ((n = inputStream.read(rgb)) >= 0) {
outputStream.write(rgb, 0, n);
}
}finally{
inputStream.close();
}

Please help.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 7 2007
Added on Nov 22 2006
11 comments
348 views