Class SimpleDownloader


  • public class SimpleDownloader
    extends Object
    A simple downloader for FTP and HTTP(s) URLs.
    Author:
    poirigui
    • Constructor Detail

      • SimpleDownloader

        public SimpleDownloader​(@Nullable
                                SimpleRetryPolicy retryPolicy)
        Parameters:
        retryPolicy - policy for retrying failed downloads, or null to only attempt downloads once
    • Method Detail

      • setFtpClientFactory

        public void setFtpClientFactory​(@Nullable
                                        FTPClientFactory ftpClientFactory)
        Set the factory for creating FTP clients.
      • setTaskExecutor

        public void setTaskExecutor​(@Nullable
                                    ExecutorService taskExecutor)
        Set the task executor for performing asynchronous downloads.
      • setCheckArchiveIntegrity

        public void setCheckArchiveIntegrity​(boolean checkArchiveIntegrity)
        Set whether to check the integrity of gzipped files after downloading.
      • downloadAsync

        public Future<Long> downloadAsync​(URL url,
                                          Path dest,
                                          boolean force)
        Download a file from a URL to a local destination asynchronously.
      • download

        public long download​(URL url,
                             Path dest,
                             boolean force)
                      throws IOException
        Download a file from a URL to a local destination.
        Parameters:
        url - URL to download
        dest - destination for the download
        force - download even if the file exists, has the same size and is up to date
        Returns:
        the number of bytes that were downloaded
        Throws:
        IOException