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 SummaryFields
- 
Method SummaryModifier and TypeMethodDescriptionstatic intcheckUrlStatus(String urlStr) Get a status code after connecting and sending an HTTP GET request to the given urlstatic intcheckUrlStatus(String urlStr, int timeoutMs) Get a status code after connecting and sending an HTTP GET request to the given url
- 
Field Details- 
DEFAULT_TIMEOUT_MSpublic static final int DEFAULT_TIMEOUT_MS- See Also:
 
 
- 
- 
Method Details- 
checkUrlStatusGet 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
 
- 
checkUrlStatuspublic 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 connected
- timeoutMs- 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
 
 
-