📄 urlparser.java
字号:
import java.net.*;
// Chapter 9, Listing 1
public class URLParser
{
public static void main(String args[])
{
int argc = args.length;
// Check for valid number of parameters
if (argc != 1)
{
System.out.println ("Syntax :");
System.out.println ("java URLParser url");
return;
}
// Catch any thrown exceptions
try
{
// Create an instance of java.net.URL
java.net.URL myURL = new URL ( args[0] );
System.out.println ("Protocol : " + myURL.getProtocol() );
System.out.println ("Hostname : " + myURL.getHost() );
System.out.println ("Port : " + myURL.getPort() );
System.out.println ("Filename : " + myURL.getFile() );
System.out.println ("Reference: " + myURL.getRef() );
}
// MalformedURLException indicates parsing error
catch (MalformedURLException mue)
{
System.err.println ("Unable to parse URL!");
return;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -