Besoin d'aide avec une "ZipException"
Bonjour,
Normalement j'aime pouvoir règler mes erreurs seul, mais celle la je n'y arrive pas.:?
J'ai créé un code pour compressé des classgen et les autre fichiers dans un .jar
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| public void Save(String filename) {
if (cgs == null || nonClass == null) {
throw new IllegalStateException("You need to load before save.");
}
FileOutputStream stream = null;
JarOutputStream out = null;
try {
byte buffer[] = new byte[10240];
stream = new FileOutputStream(filename);
out = new JarOutputStream(stream);
for(ClassGen cg :cgs){ //cgs = array de classgen
String cName = cg.getClassName();
cName=cName.replace('.', File.separatorChar)+".class";
System.out.println(cName);
try{
out.putNextEntry(new JarEntry(cName));
}catch(ZipException zex){
System.err.println("Error: "+cName);
zex.printStackTrace();
}
out.write(cg.getJavaClass().getBytes());
out.flush();
}
for (JarEntry entry : nonClass.keySet()) { //nonClass = Hashmap<JarEntry, InputStream>
out.putNextEntry(entry);
InputStream in = nonClass.get(entry);
int nRead=0;
while((nRead = in.read(buffer, 0, buffer.length))>0){
out.write(buffer, 0, nRead);
}
in.close();
}
out.close(); //line 138
stream.close();
} catch (IOException ex) {
ex.printStackTrace();
}
} |
Et sa me donne sa comme erreur:
Code:
1 2 3 4 5 6 7
| java.util.zip.ZipException: invalid entry compressed size (expected 36656 but got 36520 bytes)
at java.util.zip.ZipOutputStream.closeEntry(ZipOutputStream.java:206)
at java.util.zip.ZipOutputStream.finish(ZipOutputStream.java:301)
at java.util.zip.DeflaterOutputStream.close(DeflaterOutputStream.java:146)
at java.util.zip.ZipOutputStream.close(ZipOutputStream.java:321)
at gabuuzz.jar.JarHandle.Save(JarHandle.java:138)
at gabuuzz.Main.main(Main.java:32) |
Quelqun aurait une idée?