code: private static void extractArchive(ArchiveInputStream input,
              File destination, FilenameFilter filter)
              throws ArchiveExtractionException {
          ArchiveEntry entry;
          try {
              final String destPath = destination.getCanonicalPath();
  
              while ((entry = input.getNextEntry()) != null) {
                  if (entry.isDirectory()) {
                      final File dir = new File(destination, entry.getName());
                      if (!dir.getCanonicalPath().startsWith(destPath)) {
                          final String msg = String.format(
                                  "Archive contains a path (%s) that would be extracted outside of the target directory.",
                                  dir.getAbsolutePath());
                          throw new AnalysisException(msg);
                      }
                      if (!dir.exists() && !dir.mkdirs()) {
                          final String msg = String.format(
                                  "Unable to create directory '%s'.",
                                  dir.getAbsolutePath());
                          throw new AnalysisException(msg);
                      }
                  } else {
                      extractFile(input, destination, filter, entry);
                  }
              }
          } catch (IOException | AnalysisException ex) {
              throw new ArchiveExtractionException(ex);
          } finally {
              FileUtils.close(input);
          }
      }
docs: Extracts files from an archive.
  
  @param input the archive to extract files from
  @param destination the location to write the files too
  @param filter determines which files get extracted
  @throws ArchiveExtractionException thrown if there is an exception
  extracting files from the archive