code: public static void tar(FileSystem sourceFs, FileSystem destFs, Path sourcePath, Path destPath) throws IOException {
      try (FSDataOutputStream fsDataOutputStream = destFs.create(destPath);
          TarArchiveOutputStream tarArchiveOutputStream = new TarArchiveOutputStream(
              new GzipCompressorOutputStream(fsDataOutputStream), ConfigurationKeys.DEFAULT_CHARSET_ENCODING.name())) {
  
        FileStatus fileStatus = sourceFs.getFileStatus(sourcePath);
  
        if (sourceFs.isDirectory(sourcePath)) {
          dirToTarArchiveOutputStreamRecursive(fileStatus, sourceFs, Optional.<Path> absent(), tarArchiveOutputStream);
        } else {
          try (FSDataInputStream fsDataInputStream = sourceFs.open(sourcePath)) {
            fileToTarArchiveOutputStream(fileStatus, fsDataInputStream, new Path(sourcePath.getName()),
                tarArchiveOutputStream);
          }
        }
      }
    }
docs: Similiar to {@link #tar(FileSystem, Path, Path)} except the source and destination {@link FileSystem} can be different.
  
  @see #tar(FileSystem, Path, Path)