Class JKHttpUtil

java.lang.Object
com.jk.core.http.JKHttpUtil

public class JKHttpUtil extends Object
The Class JKHttpUtil.
  • Constructor Details

    • JKHttpUtil

      public JKHttpUtil()
  • Method Details

    • downloadFile

      public static void downloadFile(String fileUrl, String localFile) throws IOException
      Download file.
      Parameters:
      fileUrl - the file url
      localFile - the local file
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • downloadFileToTemp

      public static File downloadFileToTemp(String fileUrl, String ext) throws IOException
      Download file to temp.
      Parameters:
      fileUrl - the file url
      ext - the ext
      Returns:
      the file
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • requestUrl

      public static String requestUrl(String url, String method, Properties header, String body)
      Request url.
      Parameters:
      url - the url
      method - the method
      header - the header
      body - the body
      Returns:
      the string
    • getUrlContents

      public static String getUrlContents(String urlString)
      Gets the url contents.
      Parameters:
      urlString - the url string
      Returns:
      the url contents
    • connect

      protected static HttpURLConnection connect(String urlString) throws MalformedURLException, IOException
      Connect.
      Parameters:
      urlString - the url string
      Returns:
      the http URL connection
      Throws:
      MalformedURLException - the malformed URL exception
      IOException - Signals that an I/O exception has occurred.
    • getValueFromUrl

      public static String getValueFromUrl(String url, String preText, int length)
      Gets the value from url.
      Parameters:
      url - the url
      preText - the pre text
      length - the length
      Returns:
      the value from url
    • getUrlInputStream

      public static InputStream getUrlInputStream(String urlString)
      Gets the url input stream.
      Parameters:
      urlString - the url string
      Returns:
      the url input stream
    • readUrlAsObject

      public static <T> T readUrlAsObject(String url, Class<T> type)
      Read url as object.
      Type Parameters:
      T - the generic type
      Parameters:
      url - the url
      type - the type
      Returns:
      the t
    • pingUrl

      public static void pingUrl(String url, int retries)
      Ping url.
      Parameters:
      url - the url
      retries - the retries
    • main

      public static void main(String[] args)
      The main method.
      Parameters:
      args - the arguments