Java URL Value Check isValid(String candidateUrl)

Here you can find the source of isValid(String candidateUrl)

Description

Check if a given string is a valid url format.

License

Apache License

Parameter

Parameter Description
candidateUrl The candidate string to validate.

Return

true if the candidateUrl string is a valid url string.

Declaration

public static boolean isValid(String candidateUrl) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.net.MalformedURLException;

import java.net.URL;

public class Main {
    /**//from   w  w  w. j  a va2s .  c o m
     * Check if a given string is a valid url format.
     * 
     * @param candidateUrl The candidate string to validate.
     * @return true if the candidateUrl string is a valid url string.
     */
    public static boolean isValid(String candidateUrl) {
        try {
            URL url = new URL(candidateUrl);
            return true;
        } catch (MalformedURLException e) {
            return false;
        }
    }
}

Related

  1. isURLExists(String URLName)
  2. isUrlInJar(URL url)
  3. isUrlResponding(String url)
  4. isUrlValid(final URL url)
  5. isUrlValid(URL url)
  6. isValid(String url)
  7. isValidChannelUrl(String url)
  8. isValidServerURL(String serverURL)
  9. isValidSuccessfulSignInURL(String url)