}
}
public static final int BUFFER = 4096;
public static void speedupZip(InputStream input, OutputStream output)
throws IOException {
ZipInputStream in = new ZipInputStream(input);
ZipOutputStream out = new ZipOutputStream(output);
ZipEntry inentry;
ZipEntry outentry;
int count;
byte[] buffer = new byte[BUFFER];
while ((inentry = in.getNextEntry()) != null) {
outentry = new ZipEntry(inentry.getName());
logger.debug("Extra: " + inentry.getExtra());
outentry.setExtra(inentry.getExtra());
logger.debug("time: " + inentry.getTime());
outentry.setTime(inentry.getTime());
logger.debug("method: " + inentry.getMethod());
outentry.setMethod(inentry.getMethod());
logger.debug("comment: " + inentry.getComment());
outentry.setComment(inentry.getComment());
logger.debug("CRC: " + inentry.getCrc());
if (inentry.getCrc() != -1) {
outentry.setCrc(inentry.getCrc());
}
logger.debug("size: " + inentry.getSize());
if (inentry.getSize() != -1) {
outentry.setSize(inentry.getSize());
}
out.putNextEntry(outentry);
if (!inentry.isDirectory()) {
if (inentry.getName().endsWith(".jar")
|| inentry.getName().endsWith(".zip")
|| inentry.getName().endsWith(".war")
|| inentry.getName().endsWith(".ear")) {
speedupZip(in, out);
} else if (inentry.getName().endsWith(".class")) {
speedup(in, inentry.getName(), out);
} else {
while ((count = in.read(buffer, 0, BUFFER)) != -1) {
out.write(buffer, 0, count);
}
}
}
out.closeEntry();
in.closeEntry();
}
out.close();
in.close();
}