Here you can find the source of resolve(String path, URI... relativeTo)
public static URI resolve(String path, URI... relativeTo) throws URISyntaxException
//package com.java2s; /******************************************************************************* * Copyright (c) 2008 The University of York. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * // w w w .j a v a2 s.c o m * Contributors: * Dimitrios Kolovos - initial API and implementation ******************************************************************************/ import java.net.URI; import java.net.URISyntaxException; public class Main { public static URI resolve(String path, URI... relativeTo) throws URISyntaxException { if (path == null) return null; final URI uri = new URI(path); if (uri.isAbsolute()) return uri; else { for (URI parent : relativeTo) { if (parent != null) { boolean parentIsJar = false; if (parent.toString().startsWith("jar:file:/")) { parentIsJar = true; parent = new URI(parent.toString().replace("jar:file:/", "jar:/")); } URI resolved = parent.resolve(path); if (resolved.isAbsolute() && resolved.getScheme() != null) { if (parentIsJar) { resolved = new URI(resolved.toString().replace("jar:/", "jar:file:/")); } return resolved; } else { return new URI(parent.toString() + path); } } } } return new URI("file://" + uri); } }