protected final void downloadFile ( final URI source , final File destination ) throws IOException { Validate . validState ( ! isStopped , "Cannot download file when the crawler is not started." ) ; Validate . validState ( ! isStopping , "Cannot download file when the crawler is stopping." ) ; Validate . notNull ( source , "The source URL cannot be null." ) ; Validate . notNull ( destination , "The destination file cannot be null." ) ; HttpGet request = new HttpGet ( source ) ; try ( CloseableHttpResponse response = httpClient . execute ( request ) ) { HttpEntity entity = response . getEntity ( ) ; if ( entity != null ) { FileUtils . copyInputStreamToFile ( entity . getContent ( ) , destination ) ; } } }
Downloads the file specified by the URL .