myurl.java

来自「精通Java核心技术源代码」· Java 代码 · 共 25 行

JAVA
25
字号
// ==================== Program Discription ==========================
// 程序名称:示例12-3: Myurl.java
// 程序目的:熟悉URL对象的创建、使用。
// ==============================================================
import java.net. *;
import java.io.*;

class Myurl
{
   public static void main(String args[])
   {
      try {
         URL url=new URL("http://www.tsinghua.edu.cn/chn/index.htm");
         System.out.println("the Protocol: "+url.getProtocol());
         System.out.println("the hostname: " +url.getHost());
         System.out.println("the port: "+url.getPort());
         System.out.println("the file:"+url.getFile());
         System.out.println(url.toString());
      }
      catch(MalformedURLException e) {
         System.out.println(e);
      }
   }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?