Class HttpUtil


  • public class HttpUtil
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      HttpUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.net.HttpURLConnection getContent​(java.lang.String httpUrlString, java.util.Properties httpRequestProperties, boolean allowRedirect)
      Execute an HTTP/HTTPS GET request and return the resulting HttpURLConnection.
      static java.lang.String getFile​(java.lang.String httpUrlString, java.util.Properties httpRequestProperties, boolean allowRedirect, java.io.File destFile)
      Download a file by executing an HTTP/HTTPS GET request.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • HttpUtil

        public HttpUtil()
    • Method Detail

      • getContent

        public static java.net.HttpURLConnection getContent​(java.lang.String httpUrlString,
                                                            java.util.Properties httpRequestProperties,
                                                            boolean allowRedirect)
                                                     throws java.net.MalformedURLException,
                                                            java.io.IOException
        Execute an HTTP/HTTPS GET request and return the resulting HttpURLConnection.
        Parameters:
        httpUrlString - HTTP/HTTPS URL
        httpRequestProperties - optional HTTP request header values to be included (may be null)
        allowRedirect - allow site redirects to be handled if true
        Returns:
        HttpURLConnection which contains information about the URL
        Throws:
        java.net.MalformedURLException - bad httpUrlString specified
        java.io.IOException - if an error occurs while executing request
      • getFile

        public static java.lang.String getFile​(java.lang.String httpUrlString,
                                               java.util.Properties httpRequestProperties,
                                               boolean allowRedirect,
                                               java.io.File destFile)
                                        throws java.net.MalformedURLException,
                                               java.io.IOException
        Download a file by executing an HTTP/HTTPS GET request.
        Parameters:
        httpUrlString - HTTP/HTTPS URL
        httpRequestProperties - optional HTTP request header values to be included (may be null)
        allowRedirect - allow site redirects to be handled if true
        destFile - destination file
        Returns:
        String representing the content-type of the file, or null if the information is not available
        Throws:
        java.net.MalformedURLException - bad httpUrlString specified
        java.io.IOException - if an error occurs while executing request