int start = 0;
while (start <= data.length - WORD) {
ZipShort headerId = new ZipShort(data, start);
int length = (new ZipShort(data, start + 2)).getValue();
if (start + WORD + length > data.length) {
throw new ZipException("data starting at " + start
+ " is in unknown format");
}
try {
ZipExtraField ze = createExtraField(headerId);
ze.parseFromLocalFileData(data, start + WORD, length);
v.addElement(ze);
} catch (InstantiationException ie) {
throw new ZipException(ie.getMessage());
} catch (IllegalAccessException iae) {
throw new ZipException(iae.getMessage());
}
start += (length + WORD);
}
if (start != data.length) { // array not exhausted
throw new ZipException("data starting at " + start
+ " is in unknown format");
}
ZipExtraField[] result = new ZipExtraField[v.size()];
v.copyInto(result);