Java URI Value Check validateUri(String uri)

Here you can find the source of validateUri(String uri)

Description

validate Uri

License

Open Source License

Declaration

public static String validateUri(String uri)
            throws java.net.MalformedURLException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.net.URL;

public class Main {
    public static String validateUri(String uri)
            throws java.net.MalformedURLException {
        final URL url;
        try {/*from w  ww  . ja v  a  2 s.c  om*/
            url = new URL(uri);
        } catch (Exception e1) {
            return ("'" + uri + "' is not a valid URL: " + e1
                    .getLocalizedMessage());
        }
        if (!"http".equals(url.getProtocol())) {
            return ("'" + uri + "' is not a valid URL: Model name must use http protocol.");
        }
        return null;
    }
}

Related

  1. isVSO(final URI uri)
  2. isWellFormedUriString(final String uriString)
  3. validateURI(final String uri)
  4. validateUri(String uri)
  5. validateURI(String uri)
  6. validateUri(String uri, String name)