Here you can find the source of isUriValid(String uri)
public static boolean isUriValid(String uri)
//package com.java2s; //License from project: Apache License import java.net.HttpURLConnection; import java.net.URL; public class Main { public static boolean isUriValid(String uri) { uri = uri.trim();//from w ww . j ava 2 s . c o m if (responseCodeOfURI(uri) == 200) return true; return false; } public static int responseCodeOfURI(String uri) { HttpURLConnection connection = null; try { URL url = new URL(uri); connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("HEAD"); int code = connection.getResponseCode(); return code; } catch (Exception ex) { return -1; } } }