Java tutorial
//package com.java2s; /* * 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); } } }