Here you can find the source of resolvePath(URI root, String subPath)
Parameter | Description |
---|---|
root | The root path |
subPath | The sub path should not start with a slash |
public static URI resolvePath(URI root, String subPath) throws URISyntaxException
//package com.java2s; //License from project: Apache License import java.net.URI; import java.net.URISyntaxException; public class Main { /**//w w w .j a va 2s. c o m * root: smb:/host/my * path: path/blub * ====> smb:/host/my/path/blub * * @param root The root path * @param subPath The sub path should not start with a slash * @return Returns the resolved path */ public static URI resolvePath(URI root, String subPath) throws URISyntaxException { String rootStr = root.toString(); if (subPath.startsWith("/")) { subPath = subPath.substring(1, subPath.length()); } return new URI(rootStr + (!rootStr.endsWith("/") ? "/" : "") + subPath); } }