📄 j_url.java
字号:
// ////////////////////////////////////////////////////////
//
// J_Url.java
//
// Created by Jun-Hai Yong, on XX xx, xxxx (Date)
// ////////////////////////////////////////////////////////
// Readme:
// An example of using class java.net.URL.
// ////////////////////////////////////////////////////////
// Using this example, please explicitly refer to the book:
// Jun-Hai Yong. Programming in Java.
// Beijing: Tsinghua University Press, 2004.
// 使用本例子,请注明引用:
// 雍俊海. Java 程序设计. 北京: 清华大学出版社, 2004.
// Please note that the author and publisher make no
// warranty of any kind on the examples provided.
// ////////////////////////////////////////////////////////
import java.net.*;
public class J_Url
{
public static void main(String args[])
{
try
{
URL url = new URL("http://www.tsinghua.edu.cn/chn/index.htm");
System.out.println("protocol = "+ url.getProtocol( ));
System.out.println("host ="+url.getHost( ));
System.out.println("filename ="+url.getFile( ));
System.out.println("port="+url.getPort( ));
System.out.println("ref="+url.getRef( ));
}
catch (MalformedURLException e)
{
System.err.println(e);
}
} // End of method: main
} // End of class: J_Url
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -