Java URL Value Check isValidURL(CharSequence urlStr)

Here you can find the source of isValidURL(CharSequence urlStr)

Description

Determines if the passed string is a valid URL

License

Apache License

Parameter

Parameter Description
urlStr The URL string to test

Return

true if is valid, false if invalid or null

Declaration

public static boolean isValidURL(CharSequence urlStr) 

Method Source Code

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

import java.net.URL;

public class Main {
    /**//  ww  w  . jav  a 2s. co  m
     * Determines if the passed string is a valid URL
     * @param urlStr The URL string to test
     * @return true if is valid, false if invalid or null
     */
    public static boolean isValidURL(CharSequence urlStr) {
        if (urlStr == null)
            return false;
        try {
            new URL(urlStr.toString());
            return true;
        } catch (Exception e) {
            return false;
        }
    }
}

Related

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