Package edu.ucsb.nceas.metacat.util
Class NetworkUtil
java.lang.Object
edu.ucsb.nceas.metacat.util.NetworkUtil
A collection of static utility methods for networking
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
checkUrlStatus
(String urlStr) Get a status code after connecting and sending an HTTP GET request to the given urlstatic int
checkUrlStatus
(String urlStr, int timeoutMs) Get a status code after connecting and sending an HTTP GET request to the given url
-
Field Details
-
DEFAULT_TIMEOUT_MS
public static final int DEFAULT_TIMEOUT_MS- See Also:
-
-
Method Details
-
checkUrlStatus
Get a status code after connecting and sending an HTTP GET request to the given url- Parameters:
urlStr
- the url that will be connected- Returns:
- the status code
- Throws:
IOException
- if an I/ O error occurs while opening the connection. Includes a possible SocketTimeoutException – if the default timeout expires before the connection can be established (@see NetworkUtil.DEFAULT_TIMEOUT_MS).IllegalArgumentException
-
checkUrlStatus
public static int checkUrlStatus(String urlStr, int timeoutMs) throws URISyntaxException, IOException Get a status code after connecting and sending an HTTP GET request to the given url- Parameters:
urlStr
- the url that will be connectedtimeoutMs
- the timeout value, in milliseconds, to be used when establishing a connection to the resource referenced by this url. A timeout of zero is interpreted as an infinite timeout. A negative timeout (i.e. timeoutMs < 0) will use the default value (@see NetworkUtil.DEFAULT_TIMEOUT_MS).- Returns:
- the status code
- Throws:
IOException
- if an I/ O error occurs while opening the connection. Includes a possible SocketTimeoutException – if the timeout expires before the connection can be established.URISyntaxException
- If the url string violates RFC 2396 or is otherwise non-valid
-