`
haishen04
  • 浏览: 3349 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
文章分类
社区版块
存档分类
最新评论

InetAddressDemo

阅读更多
package socket;

//InetAddressDemo.java

import java.net.*;

class InetAddressDemo
{
  public static void main (String [] args) throws UnknownHostException
  {
    String host = "localhost";

    if (args.length == 1)
      host = args [0];

    InetAddress ia = InetAddress.getByName (host);

    System.out.println ("Canonical Host Name = " +
                ia.getCanonicalHostName ());
    System.out.println ("Host Address = " +
                ia.getHostAddress ());
    System.out.println ("Host Name = " +
                ia.getHostName ());
    System.out.println ("Is Loopback Address = " +
                ia.isLoopbackAddress ());
  }
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics