if (nextEntry.getName().endsWith(name)) {
pathToReplace = nextEntry.getName();
}
newArchiveOut.putArchiveEntry(nextEntry);
IOUtils.copy(archiveIn, newArchiveOut);
newArchiveOut.closeArchiveEntry();
}
if (pathToReplace == null) {
throw new IllegalStateException("Could not find file " + name + " in the given archive.");
}