Here you can find the source of isHttpOk(String url)
public static boolean isHttpOk(String url)
//package com.java2s; //License from project: Open Source License import java.net.HttpURLConnection; import java.net.URL; public class Main { public static boolean isHttpOk(String url) { HttpURLConnection conn = null; try {//from w ww . ja va 2 s . com URL serverUrl = new URL(url); conn = (HttpURLConnection) serverUrl.openConnection(); conn.setConnectTimeout(1000 * 5);// 5s conn.setRequestMethod("GET"); conn.connect(); int state = conn.getResponseCode(); if (state == 200) { return true; } } catch (Exception e) { System.out.println(e.getMessage()); } finally { conn.disconnect(); } return false; } }