code: public File extractZipEntry(File dir, ZipFile zipFile, ZipEntry entry) throws IOException {
      File outputFile = new File(dir, entry.getName());
      File parentFile = outputFile.getParentFile();
      if (!outputFile.getCanonicalPath().startsWith(dir.getCanonicalPath() + File.separator)
          || (!parentFile.isDirectory() && !parentFile.mkdirs())) {
        throw new IOException("Could not extract " + entry.getName() + " to " + dir.getPath());
      }
      try (InputStream inputStream = zipFile.getInputStream(entry);
          FileOutputStream outputStream = new FileOutputStream(outputFile)) {
        byte[] buf = new byte[1024];
        int n;
        while ((n = inputStream.read(buf)) > 0) {
          outputStream.write(buf, 0, n);
        }
      }
      return outputFile;
    }
docs: Extract a ZipEntry to the specified directory.