package com.mozq.boot.kuayu01.demo;
import java.net.MalformedURLException;
import java.net.URL;
public class URL_01 {
public static void main(String[] args) {
try {
URL url = new URL("");
/*
URL url = new URL("");
java.net.MalformedURLException: no protocol:
at java.net.URL.<init>(URL.java:593)
at java.net.URL.<init>(URL.java:490)
at java.net.URL.<init>(URL.java:439)
*/
/*
URL url = new URL(null);
java.net.MalformedURLException
at java.net.URL.<init>(URL.java:627)
at java.net.URL.<init>(URL.java:490)
at java.net.URL.<init>(URL.java:439)
at com.mozq.boot.kuayu01.demo.URL_01.main(URL_01.java:10)
Caused by: java.lang.NullPointerException
at java.net.URL.<init>(URL.java:532)
... 3 more
*/
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
}
原文:https://www.cnblogs.com/mozq/p/12001025.html