Class GetURL

java.lang.Object
org.deltava.dao.http.DAO
org.deltava.dao.http.GetURL

public class GetURL extends DAO
A Data Access Object to download a file via HTTP.
Since:
5.0
Version:
11.6
Author:
Luke
  • Constructor Details

    • GetURL

      public GetURL(String url, String fileName)
      Initializes the Data Access Object
      Parameters:
      url - the URL to download from
      fileName - the file to save the contents to
  • Method Details

    • getStatusCode

      public int getStatusCode()
      Returns the HTTP status code for this request.
      Returns:
      the HTTP status code
    • setForce

      public void setForce(boolean doForce)
      Forces file download even if the remote resource has not changed.
      Parameters:
      doForce - TRUE if download is forced, otherwise FALSE
    • setIfModifiedSince

      public void setIfModifiedSince(Instant dt)
      Updates the timestamp used to send an If-Modified-Since header.
      Parameters:
      dt - the date/time
    • download

      public File download() throws DAOException
      Downloads the file.
      Returns:
      TRUE if a new copy was downloaded, otherwise FALSE
      Throws:
      DAOException - if an error occurs
    • load

      public byte[] load() throws DAOException
      Loads a URL into a buffer.
      Returns:
      the buffer
      Throws:
      DAOException - if an error occurs
    • isAvailable

      public boolean isAvailable() throws DAOException
      Checks whether the URL is available for download.
      Returns:
      TRUE if content is available, otherwise FALSE
      Throws:
      DAOException - if an unexpected error occurs