Here you can find the source of isValidURL(String URL_String)
Parameter | Description |
---|---|
URL_String | the URL to test |
public static boolean isValidURL(String URL_String)
//package com.java2s; //License from project: Open Source License import java.net.MalformedURLException; import java.net.URISyntaxException; import java.net.URL; public class Main { /**//from w w w . ja v a 2 s . c o m * Opens up a connection with the given URL and returns true if the response code is 200 (success) * @param URL_String the URL to test * @return Host reachability */ public static boolean isValidURL(String URL_String) { try { URL url = new URL(URL_String); url.toURI(); } catch (MalformedURLException e) { return false; } catch (URISyntaxException e) { return false; } return true; } }