@Test public void existingAddressIsReachable() throws Exception { val host = "www.google.com"; val port = 443; val timeout = 10000; assertTrue(isReachable(host, port, timeout)); }
public static boolean isReachable(final String hostName, int port, int timeout) { try (Socket socket = new Socket()) { socket.connect(new InetSocketAddress(hostName, port), timeout); return true; } catch (IOException ignore) { return false; } }
HttpUtils { public static boolean isReachable(final String hostName, int port, int timeout) { try (Socket socket = new Socket()) { socket.connect(new InetSocketAddress(hostName, port), timeout); return true; } catch (IOException ignore) { return false; } } }
HttpUtils { public static boolean isReachable(final String hostName, int port, int timeout) { try (Socket socket = new Socket()) { socket.connect(new InetSocketAddress(hostName, port), timeout); return true; } catch (IOException ignore) { return false; } } private  HttpUtils(); }
HttpUtils { public static boolean isReachable(final String hostName, int port, int timeout) { try (Socket socket = new Socket()) { socket.connect(new InetSocketAddress(hostName, port), timeout); return true; } catch (IOException ignore) { return false; } } private  HttpUtils(); static boolean isReachable(final String hostName, int port, int timeout); static URL buildURL(final String hostName, final Map<String, String> query); }
HttpUtils { public static boolean isReachable(final String hostName, int port, int timeout) { try (Socket socket = new Socket()) { socket.connect(new InetSocketAddress(hostName, port), timeout); return true; } catch (IOException ignore) { return false; } } private  HttpUtils(); static boolean isReachable(final String hostName, int port, int timeout); static URL buildURL(final String hostName, final Map<String, String> query);  }