Here you can find the source of isValidURL(String urlStr)
Parameter | Description |
---|---|
urlStr | URL string to check |
public static boolean isValidURL(String urlStr)
//package com.java2s; //License from project: Open Source License import java.net.URI; import java.net.URISyntaxException; public class Main { /**//from w ww.j a v a2 s. c o m * Checks whether the given string is a valid URL. * * @param urlStr URL string to check * @return true if valid URL, else false */ public static boolean isValidURL(String urlStr) { if (urlStr == null) { return false; } try { URI uri = new URI(urlStr); if (uri.getScheme() == null) { return false; } return uri.getScheme().equals("http") || uri.getScheme().equals("https"); } catch (URISyntaxException e) { return false; } } }