Java URI Value Check validateURI(final String uri)

Here you can find the source of validateURI(final String uri)

Description

Just test to see if the given string can be parse into a URI.

License

Open Source License

Parameter

Parameter Description
uri a parameter

Return

TODO Complete Documentation

Declaration

public static URI validateURI(final String uri) 

Method Source Code

//package com.java2s;
/*/* w w w  .  jav a  2 s.  c  o m*/
 * Copyright (c) 2006 Stephan D. Cote' - All rights reserved.
 * 
 * This program and the accompanying materials are made available under the 
 * terms of the MIT License which accompanies this distribution, and is 
 * available at http://creativecommons.org/licenses/MIT/
 *
 * Contributors:
 *   Stephan D. Cote 
 *      - Initial concept and implementation
 */

import java.net.URI;

public class Main {
    /**
     * Just test to see if the given string can be parse into a URI.
     *
     * @param uri
     *
     * @return TODO Complete Documentation
     */
    public static URI validateURI(final String uri) {
        try {
            // We could try to open it, but even if it succeeds now, it may fail later
            // or if it fails right now, it may succeede later. So what is the use?
            return new URI(uri);
        } catch (final Exception mfue) {
            // System.err.println( "NetUtil.validateURI(String) The URI \"" + uri + "\" is not valid:\n" );
        }

        return null;
    }
}

Related

  1. isValidURIorEmpty(String uri)
  2. isValidURIReference(String uriRef)
  3. isVirtual(URI locationURI)
  4. isVSO(final URI uri)
  5. isWellFormedUriString(final String uriString)
  6. validateUri(String uri)
  7. validateURI(String uri)
  8. validateUri(String uri)
  9. validateUri(String uri, String name)