public void putNextEntry(ZipEntry ze) throws IOException {
if (firstEntry) {
// Make sure that extra field data for first JAR
// entry includes JAR magic number id.
byte[] edata = ze.getExtra();
if (edata == null || !hasMagic(edata)) {
if (edata == null) {
edata = new byte[4];
} else {
// Prepend magic to existing extra data
byte[] tmp = new byte[edata.length + 4];
System.arraycopy(edata, 0, tmp, 4, edata.length);
edata = tmp;
}
set16(edata, 0, JAR_MAGIC); // extra field id
set16(edata, 2, 0); // extra field size
ze.setExtra(edata);
}
firstEntry = false;
}
super.putNextEntry(ze);
}
Begins writing a new JAR file entry and positions the stream
to the start of the entry data. This method will also close
any previous entry. The default compression method will be
used if no compression method was specified for the entry.
The current time will be used if the entry has no set modification
time. |