Java tutorial
//package com.java2s; /* * Copyright 2000-2013 Enonic AS * http://www.enonic.com/license */ import java.net.URI; import java.net.URLDecoder; public class Main { public static String resolvePath(final String path) { try { final URI uri = new URI(path); return removeExtraSlashes(URLDecoder.decode(uri.getPath(), "UTF-8")); } catch (final Exception e) { throw new RuntimeException(e); } } private static String removeExtraSlashes(final String str) { if (str.contains("//")) { return removeExtraSlashes(str.replace("//", "/")); } else { return str; } } }