40 import java.io.IOException;
41 import java.io.UncheckedIOException;
42 import java.nio.file.*;
44 import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
57 public static void main(String[] args) {
58 if (args.length != 1) {
59 System.out.println(
"Usage: Unzip zipfile");
61 final Path destDir = Paths.get(
".");
66 try (FileSystem zipFileSystem = FileSystems.newFileSystem(Paths.get(args[0]),
null)) {
68 Path top = zipFileSystem.getPath(
"/");
69 Files.walk(top).skip(1).forEach(
file -> {
70 Path target = destDir.resolve(top.relativize(
file).toString());
71 System.out.println(
"Extracting " + target);
73 Files.copy(file, target, REPLACE_EXISTING);
74 } catch (IOException e) {
75 throw new UncheckedIOException(e);
78 }
catch (UncheckedIOException | IOException e) {