for (int i = 0; i < count; i++) {
try {
Section one = sections[i];
int zeroCount = one.getFileOffset() - out.getCursor();
if (zeroCount < 0) {
throw new ExceptionWithContext("excess write of " +
(-zeroCount));
}
out.writeZeroes(one.getFileOffset() - out.getCursor());
one.writeTo(out);
} catch (RuntimeException ex) {
ExceptionWithContext ec;
if (ex instanceof ExceptionWithContext) {
ec = (ExceptionWithContext) ex;
} else {
ec = new ExceptionWithContext(ex);
}
ec.addContext("...while writing section " + i);
throw ec;
}
}
if (out.getCursor() != fileSize) {