Java URL Value Check isUrl(String s)

Here you can find the source of isUrl(String s)

Description

is Url

License

CDDL license

Declaration

public static boolean isUrl(String s) 

Method Source Code

//package com.java2s;
//License from project: CDDL license 

import java.net.URL;
import java.net.MalformedURLException;

public class Main {
    public static boolean isUrl(String s) {
        if (true) {
            try {
                URL u = new URL(s);
                return (u != null);
            } catch (MalformedURLException e) {
                return false;
            }/*ww  w  . j a  v  a  2 s .c  o  m*/
        } else {
            if (s == null)
                return false;
            s = s.toLowerCase();
            if (s.startsWith("http://"))
                return true;
            else if (s.startsWith("ftp://"))
                return true;
            else if (s.startsWith("file:"))
                return true;
            // what other forms does java url handle?
            else
                return false;
        }
    }
}

Related

  1. isURL(String name)
  2. isURL(String possibleURL)
  3. isUrl(String resourceLocation)
  4. isUrl(String resourceLocation)
  5. isUrl(String s)
  6. isURL(String str)
  7. isURL(String token)
  8. isUrl(String value)
  9. isURLAccessible(String URL)