//绝对路径
String absolutePath = "http://www.aaa.com/1/2/3.html";
//相对路径
String relativePath = "../../a.jpg";
//以下方法对相对路径进行转换
URL absoluteUrl = new URL(absolutePath);
URL parseUrl = new URL(absoluteUrl ,relativePath );
//最终结果
log.info("相对路径转换后的绝对路径:" + parseUrl .toString());
本文介绍了一种将相对路径转换为绝对路径的方法,通过使用Java的URL类实现路径转换,并提供了具体的代码示例。
713

被折叠的 条评论
为什么被折叠?



