net_ip_01.java

来自「处学java 用的是jdk」· Java 代码 · 共 26 行

JAVA
26
字号
//net_ip_01.java
//10.2 04
//

import java.net.*;

//************************************************************
public class net_ip_01 
{
  public static void main(String[] args){
    try{
      if(args.length==1){
        InetAddress ipa = InetAddress.getByName(args[0]);
        System.out.println("Host name:" + ipa.getHostName());
        System.out.println("Host IP address:" + ipa.toString());
        System.out.println("Local Host:" + InetAddress.getLocalHost());
      }
      else
        System.out.println("Please input a host name as the parameter!");   
    }
    catch(UnknownHostException e){    
      System.out.println(e.toString());
    }
  }
}      
      

⌨️ 快捷键说明

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