Package com.jk.core.http
Class JKHttpUtil
java.lang.Object
com.jk.core.http.JKHttpUtil
The Class JKHttpUtil.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static HttpURLConnection
Connect.static void
downloadFile
(String fileUrl, String localFile) Download file.static File
downloadFileToTemp
(String fileUrl, String ext) Download file to temp.static String
getUrlContents
(String urlString) Gets the url contents.static InputStream
getUrlInputStream
(String urlString) Gets the url input stream.static String
getValueFromUrl
(String url, String preText, int length) Gets the value from url.static void
The main method.static void
Ping url.static <T> T
readUrlAsObject
(String url, Class<T> type) Read url as object.static String
requestUrl
(String url, String method, Properties header, String body) Request url.
-
Constructor Details
-
JKHttpUtil
public JKHttpUtil()
-
-
Method Details
-
downloadFile
Download file.- Parameters:
fileUrl
- the file urllocalFile
- the local file- Throws:
IOException
- Signals that an I/O exception has occurred.
-
downloadFileToTemp
Download file to temp.- Parameters:
fileUrl
- the file urlext
- the ext- Returns:
- the file
- Throws:
IOException
- Signals that an I/O exception has occurred.
-
requestUrl
Request url.- Parameters:
url
- the urlmethod
- the methodheader
- the headerbody
- the body- Returns:
- the string
-
getUrlContents
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 exceptionIOException
- Signals that an I/O exception has occurred.
-
getValueFromUrl
Gets the value from url.- Parameters:
url
- the urlpreText
- the pre textlength
- the length- Returns:
- the value from url
-
getUrlInputStream
Gets the url input stream.- Parameters:
urlString
- the url string- Returns:
- the url input stream
-
readUrlAsObject
Read url as object.- Type Parameters:
T
- the generic type- Parameters:
url
- the urltype
- the type- Returns:
- the t
-
pingUrl
Ping url.- Parameters:
url
- the urlretries
- the retries
-
main
The main method.- Parameters:
args
- the arguments
-