if (off >= 0L) {
this.archive.seek(off);
sig = ZipOutputStream.EOCD_SIG;
for(int curr = this.archive.read(); curr != -1; curr = this.archive.read()) {
if (curr == sig[0]) {
curr = this.archive.read();
if (curr == sig[1]) {
curr = this.archive.read();
if (curr == sig[2]) {
curr = this.archive.read();
if (curr == sig[3]) {
found = true;
break;
}
}
}
}
如上,代码为ZipFile.class中的positionAtCentralDirectory()方法,请问:代码中的ZipOutputStream.EOCD_SIG字段代表什么意思?this.archive.read()又代表什么意思?为什么这两个要进行值匹配?谢谢!!!
private void positionAtCentralDirectory() throws IOException {
boolean found = false;
long off = this.archive.length() - 22L;
byte[] sig;
if (off >= 0L) {
this.archive.seek(off);
sig = ZipOutputStream.EOCD_SIG;
for(int curr = this.archive.read(); curr != -1; curr = this.archive.read()) {
if (curr == sig[0]) {
curr = this.archive.read();
if (curr == sig[1]) {
curr = this.archive.read();
if (curr == sig[2]) {
curr = this.archive.read();
if (curr == sig[3]) {
found = true;
break;
}
}
}
}
this.archive.seek(--off);
}
}
if (!found) {
throw new ZipException("archive is not a ZIP archive");
} else {
this.archive.seek(off + 16L);
sig = new byte[4];
this.archive.readFully(sig);
this.archive.seek(ZipLong.getValue(sig));
}
}