Download of Zip file not working.
807603Nov 22 2006 — edited Jan 10 2007I 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.