1: 将 URI 转换为 URL
java">import java.net.URI;
import java.net.URL;public class UriToUrlExample {public static void main(String[] args) {// 创建一个 URI 对象URI uri = new URI("http://example.com/path/to/resource");// 将 URI 转换为 URLtry {URL url = uri.toURL();System.out.println("URL: " + url);} catch (Exception e) {e.printStackTrace();}}
}
2: 将 URL 转换为 URI
java">import java.net.URI;
import java.net.URL;public class UrlToUriExample {public static void main(S