解析URL
import java.net.MalformedURLException; import java.net.URL;/** 来自 n o w j a v a . c o m - 时 代 Java**/ public class Main { public static void main(String[] argv) { try { URL url = new URL("http://hostname:80/index.html#_top_"); String protocol = url.getProtocol(); // http String host = url.getHost(); // hostname int port = url.getPort(); // 80 String file = url.getFile(); // index.html