boolean (PatchSpec spec, Path cacheDir) { boolean success = false; try { File tempPatchFile = Utils.getTempFile("patch"); PatchFileCreator.create(spec, tempPatchFile, cacheDir); LOG.info("Packing JAR file: " + spec.getPatchFile()); System.out.println("Packing JAR file '" + spec.getPatchFile() + "'..."); try (ZipOutputWrapper out = new ZipOutputWrapper(Files.newOutputStream(Path.of(spec.getPatchFile()), StandardOpenOption.CREATE_NEW)); ZipInputStream in = new ZipInputStream(Files.newInputStream(Path.of(spec.getJarFile())))) { ZipEntry e; while ((e = in.getNextEntry()) != null) { out.zipEntry(e, in); } out.zipFile(PATCH_FILE_NAME, tempPatchFile); out.finish(); } success = true; } catch (Throwable t) { LOG.log(Level.SEVERE, "create failed", t); t.printStackTrace(System.err); } finally { try { System.out.println("Cleaning up..."); LOG.info("Cleaning up..."); Utils.cleanup(); } catch (Throwable t) { success = false; LOG.log(Level.SEVERE, "cleanup failed", t); t.printStackTrace(System.err); } } return success; }