Here you can find the source of normalizeURIPath(String uri)
public static String normalizeURIPath(String uri)
//package com.java2s; //License from project: Open Source License import java.net.URI; import java.net.URISyntaxException; public class Main { public static String normalizeURIPath(String uri) { if (uri.indexOf('%') < 0 && !uri.startsWith("./") && !uri.startsWith("../") && !uri.endsWith("/.") && !uri.endsWith("/..") && uri.indexOf("/../") < 0 && uri.indexOf("/./") < 0 && uri.indexOf("//") < 0) { // Nothing %-encoded, and no special path elements return uri; }// ww w. j av a 2s . co m try { uri = new URI(uri).normalize().getPath(); } catch (URISyntaxException e) { throw (IllegalArgumentException) new IllegalArgumentException("Malformed URI [" + uri + "]") .initCause(e); } if (uri.equals("")) { uri = "/"; } else if (!uri.equals("/") && uri.endsWith("/")) { uri = uri.substring(0, uri.length() - 1); } return uri; } }