提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
一个演示使用java.net.URL类的示例类
import java.net.URL; public class Main {//来 自 时 代 Java - nowjava.com public static void main(String[] args) { String baseURLStr = "http://www.ietf.org/rfc/rfc3986.txt"; String relativeURLStr = "rfc2732.txt"; try { URL baseURL = new URL (baseURLStr); URL resolvedRelativeURL = new URL(baseURL, relativeURLStr); System.out.println("Base URL:" + baseURL); System.out.println("Relative URL String:" + relativeURLStr); System.out.println("Resolved Relative URL:" +