Here you can find the source of isUrlResponding(String url)
public static boolean isUrlResponding(String url)
//package com.java2s; //License from project: Open Source License import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; public class Main { public static boolean isUrlResponding(String url) { try {/* w w w .ja v a 2 s. c om*/ return isUrlResponding(new URL(url)); } catch (MalformedURLException e) { } return false; } public static boolean isUrlResponding(URL url) { try { HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("HEAD"); int code = conn.getResponseCode(); // System.out.println(url+" => ["+code+"]"); // if( code/100 == 4 ) return false; return code / 100 == 2; } catch (Exception e) { } return false; } }