ZIP problem on Netware
Below there is a program which updates an OpenOffice file, in fact a zip file.
It works fine on window but on Netware I receive an exception
java.util.zip.ZipException: invalid entry CRC-32
(expected oxffffffffc0f3d518 but got 0xc0f3d518)
Any ideas is great appreciated. Thanks!
(JDK 1.4.2 on both OS)
================
import java.io.*;
import java.util.*;
import java.util.zip.*;
import java.util.jar.*;
class test {
public static void main(String []args){
test ob=new test();
ob.updateZipEntry("data://test.sxw","content.xml","data:");
}
void updateZipEntry(String jarName, String fileName, String location){
try {
File jarFile = new File(jarName);
File tempJarFile = new File(jarName + ".tmp");
JarFile jar = new JarFile(jarFile);
boolean jarUpdated = false;
try {
Manifest jarManifest = jar.getManifest();
JarOutputStream tempJar = new JarOutputStream(new FileOutputStream(tempJarFile));
byte[] buffer = new byte[1024];
int bytesRead;
try {
FileInputStream file = new FileInputStream(location+"//"+fileName);
try {
JarEntry entry = new JarEntry(fileName);
tempJar.putNextEntry(entry);
while ((bytesRead = file.read(buffer)) != -1) {
tempJar.write(buffer, 0, bytesRead);
}
}
finally { file.close(); }
for (Enumeration entries = jar.entries(); entries.hasMoreElements(); ) {
JarEntry entry = (JarEntry) entries.nextElement();
if (! entry.getName().equals(fileName)) {
InputStream entryStream = jar.getInputStream(entry);
tempJar.putNextEntry(entry);
while ((bytesRead = entryStream.read(buffer)) != -1) {
tempJar.write(buffer, 0, bytesRead);
}
}
}
jarUpdated = true;
}
catch (Exception ex) {
System.out.println(ex);
tempJar.putNextEntry(new JarEntry("stub"));
}
finally { tempJar.close(); }
}
finally {
jar.close();
if (! jarUpdated) { tempJarFile.delete(); }
}
if (jarUpdated) {
jarFile.delete();
tempJarFile.renameTo(jarFile);
}
} catch(IOException e) {}
} // end updateZipEntry
}

