public class HttpUtils
extends java.lang.Object
This class provides some simple connectivity utilities which may be common when trying to get information about an HTTP connection.
Modifier and Type | Class and Description |
---|---|
protected static class |
HttpUtils.TrustAllX509TrustManager |
Modifier and Type | Field and Description |
---|---|
static int |
RESPONSE_OK |
Constructor and Description |
---|
HttpUtils() |
Modifier and Type | Method and Description |
---|---|
static boolean |
isOkResponse(java.lang.String address)
This static method will try to resolve a URL passed in as a string, and if successful, will try to determine
if the response given is an "OK" response (aka, code 200).
|
static boolean |
isOkResponse(java.lang.String address,
int timeout)
This static method will try to resolve a URL passed in as a string, and if successful, will try to determine
if the response given is an "OK" response (aka, code 200).
|
static boolean |
isOkResponse(java.net.URL url)
Makes a test connection to the provided URL.
|
static boolean |
isOkResponse(java.net.URL url,
int timeout) |
public static final int RESPONSE_OK
public static boolean isOkResponse(java.net.URL url) throws java.io.IOException
This method is useful when trying to verify that a URL is online and has a valid site available. Omitting the timeout parameter uses 0, or an infinite timeout
url
- the URL that will be tested for connection/content quality.java.io.IOException
public static boolean isOkResponse(java.net.URL url, int timeout) throws java.io.IOException
java.io.IOException
public static boolean isOkResponse(java.lang.String address) throws java.net.MalformedURLException
address
- which is the url to be tested for connectivityjava.net.MalformedURLException
public static boolean isOkResponse(java.lang.String address, int timeout) throws java.net.MalformedURLException
address
- which is the url to be tested for connectivitytimeout
- connection timeout in millisjava.net.MalformedURLException