code: protected Map<String, String> retrieveToFile(File localFile, RetrievalListener listener) throws IOException {
  
          try {
              contentStream = new Retrier(5, 4000, 3).execute(() -> {
                  return source.getSourceContent(contentItem, listener);
              });
          } catch (Exception ex) {
              throw new IOException(ex);
          }
  
          try (
              InputStream inStream = contentStream.getStream();
              OutputStream outStream = new FileOutputStream(localFile);
          ) {
              IOUtils.copyLarge(inStream, outStream);
          } catch (IOException e) {
              try {
                  deleteFile(localFile);
              } catch (IOException ioe) {
                  logger.error("Exception deleting local file " +
                               localFile.getAbsolutePath() + " due to: " + ioe.getMessage());
              }
              throw e;
          }
  
          if (!checksumsMatch(localFile, contentStream.getChecksum())) {
              deleteFile(localFile);
              throw new IOException("Calculated checksum value for retrieved " +
                                    "file does not match properties checksum.");
          }
  
          // Set time stamps
          if (applyTimestamps) {
              applyTimestamps(contentStream, localFile);
          }
          return contentStream.getProperties();
      }
docs: Transfers the remote file stream to the local file
  
  @param localFile
  @param listener
  @return
  @throws IOException
  @returns the checksum of the File upon successful retrieval.  Successful
  retrieval means the checksum of the local file and remote file match,
  otherwise an IOException is thrown.