创建一个URL
import java.net.MalformedURLException;/*时 代 J a v a - nowjava.com*/ import java.net.URL; public class Main { public static void main(String[] args) throws Exception { try { // With components. URL url = new URL("http", "hostname", 80, "index.html"); // With a single string. url = new URL("http://hostname:80/index.html"); } catch (MalformedURLException e) { } } }