Java URL Value Check isURL(String str)

Here you can find the source of isURL(String str)

Description

is URL

License

Open Source License

Declaration

public static boolean isURL(String str) 

Method Source Code

//package com.java2s;
/* J_LZ_COPYRIGHT_BEGIN *******************************************************
* Copyright 2001-2004, 2010-2011 Laszlo Systems, Inc.  All Rights Reserved.   *
* Use is subject to license terms.                                            *
* J_LZ_COPYRIGHT_END *********************************************************/

public class Main {
    public static boolean isURL(String str) {
        // when running in ant, some of these protocols (https and soap, at
        // least) throw MalformedURLException
        if (str.startsWith("http:") || str.startsWith("https:") || str.startsWith("file:") || str.startsWith("ftp:")
                || str.startsWith("soap:")) {
            return true;
        }/*from w  w w  .  j a  va  2s  .  c om*/
        try {
            new java.net.URL(str); // for effect
            return true;
        } catch (java.net.MalformedURLException e) {
            return false;
        }
    }
}

Related

  1. isURL(String possibleURL)
  2. isUrl(String resourceLocation)
  3. isUrl(String resourceLocation)
  4. isUrl(String s)
  5. isUrl(String s)
  6. isURL(String token)
  7. isUrl(String value)
  8. isURLAccessible(String URL)
  9. isURLAvailable(String url, int timeout)