inetaddresstest.java
来自「这是java2核心技术第七版的源代码」· Java 代码 · 共 39 行
JAVA
39 行
/**
@version 1.01 2001-06-26
@author Cay Horstmann
*/
import java.net.*;
/**
This program demonstrates the InetAddress class.
Supply a host name as command line argument, or run
without command line arguments to see the address of the
local host.
*/
public class InetAddressTest
{
public static void main(String[] args)
{
try
{
if (args.length > 0)
{
String host = args[0];
InetAddress[] addresses = InetAddress.getAllByName(host);
for (InetAddress a : addresses)
System.out.println(a);
}
else
{
InetAddress localHostAddress = InetAddress.getLocalHost();
System.out.println(localHostAddress);
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?