Java URL Value Check isValidURL(final String candidateString)

Here you can find the source of isValidURL(final String candidateString)

Description

Checks that the specified string meets the requirements of the URL specification.

License

Open Source License

Parameter

Parameter Description
candidateString The string to be validated.

Return

True if the specified string qualifies as a and False otherwise.

Declaration

public static boolean isValidURL(final String candidateString) 

Method Source Code

//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;
    }
}

Related

  1. isValid(String url)
  2. isValidChannelUrl(String url)
  3. isValidServerURL(String serverURL)
  4. isValidSuccessfulSignInURL(String url)
  5. isValidURL(CharSequence urlStr)
  6. isValidURL(String link)
  7. isValidURL(String url)
  8. isValidURL(String url)
  9. isValidURL(String url)