How to quickly check if URL server is available

后端 未结 8 2033
执念已碎
执念已碎 2020-12-09 16:30

I have a URL in the form

http://www.mywebsite.com/util/conv?a=1&from=%s&to=%s

And want to check if it is available.

The lin

8条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-09 16:42

    I had similar problem last month and someone helped me out with an optional example. I'd like to suggest you the same

    public boolean isServerReachable()
        // To check if server is reachable
        {
            try {
                InetAddress.getByName("google.com").isReachable(3000); //Replace with your name
                return true;
            } catch (Exception e) {
                return false;
            }
        }
    

    if return true than your url server is available else is not available currently.

提交回复
热议问题