Class Download

    • Constructor Detail

      • Download

        public Download​(String url,
                        int timeout)
                 throws MalformedURLException
        The constructor specifies the URL.
        Parameters:
        url - The URL for downloading.
        timeout - The timeout for a download request in milliseconds.
        Throws:
        MalformedURLException - Thrown if the URL is malformed.
    • Method Detail

      • downloadArray

        public byte[] downloadArray()
                             throws IOException
        This method downloads a HTTP resource and returns it as an byte array.
        Returns:
        The downloaded byte array.
        Throws:
        IOException - Thrown if womething went wrong.
      • getMimeType

        public String getMimeType()
        This getter returns the mime type of the downloaded byte array. This is only defined after using downloadArray(), otherwise the return value is always null.
        Returns:
        The mime type of the downloadArray() method call or null otherwise.
      • getUrl

        public String getUrl()
        This method returns the used URL.
        Returns:
        The used URL.
      • getTimeout

        public int getTimeout()
        This method returns the connection timeout.
        Returns:
        The connection timeout.
      • setTimeout

        public void setTimeout​(int timeout)
        This method sets a new timeout.
        Parameters:
        timeout - The new timeout.
      • getFollowRedirect

        public boolean getFollowRedirect()
        This method returns a flag whether this download instance should follow redirects
        Returns:
        Flag if this instance should process redirects.
      • setFollowRedirect

        public void setFollowRedirect​(boolean redirect)
        This method sets the behavior concerning redirects.
        Parameters:
        redirect - The flag which sets the redirect behavior of this instance.
      • resolve

        public static InetAddress resolve​(String fqhn)
                                   throws UnknownHostException
        This method resolves a full qualified hostname into an IP address.
        Parameters:
        fqhn - The hostname to resolve.
        Returns:
        The IP address if resolvable.
        Throws:
        UnknownHostException - If the hostname cannot be resolved.