Class NetworkUtil

java.lang.Object
edu.ucsb.nceas.metacat.util.NetworkUtil

public class NetworkUtil extends Object
A collection of static utility methods for networking
  • Field Details

  • Method Details

    • checkUrlStatus

      public static int checkUrlStatus(String urlStr) throws IOException, IllegalArgumentException
      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 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