public static String getAbsoluteURL(String baseURI, String relativePath) {
String abURL = null;
try {
URI base = new URI(baseURI);// 基本网页URI
URI abs = base.resolve(relativePath);// 解析于上述网页的相对URL,得到绝对URI
URL absURL = abs.toURL();// 转成URL
abURL = absURL.toString();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (URISyntaxException e) {
e.printStackTrace();
} finally {
return abURL;
}
}
相对路径转成绝对路径
最新推荐文章于 2024-06-26 09:47:17 发布