Java URI Create convertToURI(String uriOrPath)

Here you can find the source of convertToURI(String uriOrPath)

Description

Converts a string representing a file or uri to a uri object.

License

Open Source License

Parameter

Parameter Description
uriOrPath uri or path to convert

Return

uri

Declaration

public static URI convertToURI(String uriOrPath) 

Method Source Code


//package com.java2s;
import java.io.File;

import java.net.URI;

public class Main {
    /**//from w  w w  .j  av  a  2  s . c om
     * Converts a string representing a file or uri to a uri object.
     *
     * @param uriOrPath
     *            uri or path to convert
     * @return uri
     */
    public static URI convertToURI(String uriOrPath) {
        if (uriOrPath.contains("://")) {
            return URI.create(uriOrPath);
        } else {
            return new File(uriOrPath).toURI();
        }
    }
}

Related

  1. addParams(final Map params, final StringBuilder uri)
  2. addParams(URI uri, Map> params, Set overridenParams)
  3. addQueryParametersToUri(URI uri, Map parameters)
  4. addQueryParamsToUri(String uri, Map queryParams)
  5. addQueryString(final URI uri, final String queryString)
  6. convertToURI(String uriString, Map aliasMap)
  7. convertToURI(String value)
  8. create(final String uri)
  9. createAbsoluteURI(URI base, String uri)