Here you can find the source of isValidURL(final String candidateString)
Checks that the specified string meets the requirements of the URL specification.
Parameter | Description |
---|---|
candidateString | The string to be validated. |
True
if the specified string qualifies as a and False
otherwise.
public static boolean isValidURL(final String candidateString)
//package com.java2s; //License from project: Open Source License import java.net.URL; public class Main { /**/*from w w w .j a v a2s . com*/ * <p> * Checks that the specified string meets the requirements of the * {@link URL} specification. * </p> * * @param candidateString * The string to be validated. * @return <code>True</code> if the specified string qualifies as a * {@link URL} and <code>False</code> otherwise. */ public static boolean isValidURL(final String candidateString) { boolean result; try { new URL(candidateString); result = true; } catch (Throwable throwable) { result = false; } return result; } }