void (Path archive, Path targetDir) { try (var zip = new ZipFile(archive.toFile())) { var entries = zip.entries(); while (entries.hasMoreElements()) { var entry = entries.nextElement(); if (!entry.isDirectory()) { if (entry.getName().contains("..")) throw new IllegalArgumentException("Invalid entry: " + entry.getName()); var file = targetDir.resolve(entry.getName()); Files.createDirectories(file.getParent()); try (InputStream in = zip.getInputStream(entry)) { Files.copy(in, file); } } } } catch (IOException e) { throw new UncheckedIOException(e); } }