public static void unzip(Path file, Path to) throws IOException {
    if (Files.notExists(to)) {
      Files.createDirectories(to);
    }

    ZipFile zipFile = new ZipFile(file.toFile());
    Enumeration<ZipEntry> entries = zipFile.getEntries();
    while (entries.hasMoreElements()) {
      ZipEntry entry = entries.nextElement();
      Path entryPath = to.resolve(entry.getName());
      if (!entry.isDirectory()) {
        if (Files.notExists(entryPath.getParent())) {
          Files.createDirectories(entryPath.getParent());
        }

        if (Files.isRegularFile(entryPath)) {
          if (Files.size(entryPath) == entry.getSize()) {
            continue;
          } else {
            Files.delete(entryPath);
          }
        }

        Files.createFile(entryPath);

        try (OutputStream os = Files.newOutputStream(entryPath)) {
          InputStream is = zipFile.getInputStream(entry);
          byte[] ba = new byte[1024];
          int read;
          while ((read = is.read(ba)) != -1) {
            if (read > 0) {
              os.write(ba, 0, read);
            }
          }
        }

        int unixMode = entry.getUnixMode();
        if (unixMode != 0) {
          Set<PosixFilePermission> permissions = FileTools.toPosixPermissions(unixMode);
          Files.setPosixFilePermissions(entryPath, permissions);
        }
      }
    }

    zipFile.close();
  }