Java URI Create createUri(final String path)

Here you can find the source of createUri(final String path)

Description

create Uri

License

Open Source License

Declaration

public static String createUri(final String path) 

Method Source Code


//package com.java2s;
/*/*w ww .  j ava 2s  .  c om*/
 * Copyright 2000-2013 Enonic AS
 * http://www.enonic.com/license
 */

import java.io.UnsupportedEncodingException;

import java.net.URLEncoder;

public class Main {
    private static final String DUMMY_PREFIX = "dummy:/";

    public static String createUri(final String path) {
        if (path.contains(":/")) {
            return path;
        }

        try {
            return DUMMY_PREFIX + URLEncoder.encode(path, "UTF-8");
        } catch (final UnsupportedEncodingException e) {
            throw new AssertionError(e);
        }
    }
}

Related

  1. createDefaultName(final String uri)
  2. createExtensionUri(final String ext)
  3. createURI()
  4. createUri(File file)
  5. createURI(final String file)
  6. createUri(final String path, final String query)
  7. createURI(final String scheme, final String host, final int port)
  8. createURI(final String scheme, final String host, int port, final String path, final String query, final String fragment)
  9. createURI(final String scheme, final String[] pathAsArray)