Hi, I need to create a zip archive with the following structure:
archive.zip
|_folder
|_subarchive.zip
|_file.jad
|_file.jar
I use the following code:
zout = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(newPackage)));
zout.putNextEntry(new ZipEntry("folder/"));
zout.putNextEntry(new ZipEntry("folder/subarchive.zip"));
//Copy the jar
ZipOutputStream ztemp = new ZipOutputStream(zout);
BufferedReader cbr = new BufferedReader(new FileReader(new File(srcFolder,"file.jar")));
ZipEntry jarEntry = new ZipEntry("file.jar");
ztemp.putNextEntry(jarEntry);
int read = 0;
BufferedReader cbr = new BufferedReader(new FileReader(new File(srcFolder,"file.jar")));
while((read = cbr.read(buffer,0,buffer.length)) > 0)
ztemp.write(toByteArray(buffer),0,read);
cbr.close();
ztemp.closeEntry();
//Copy the jad
ztemp.putNextEntry(new ZipEntry("file.jad"));
cbr = new BufferedReader(new FileReader(new File(srcFolder,"file.jad")));
read = 0;
while((read = cbr.read(buffer,0,buffer.length)) >= 0)
ztemp.write(toByteArray(buffer),0,read);
cbr.close();
ztemp.closeEntry();
ztemp.finish();
zout.close();
The archive is created withe the correct structure, when i extract it to test it i see that the jad is ok, and If i open the jar with winrar it contains the correct structure (the same as the original jar), but if I try to extract it I get CRC errors for every file in the archive and the jar results corrupted... how can I solve this?
Thanks bye.