81,091
社区成员
发帖
与我相关
我的任务
分享
import java.net.*;
public class InetAddressTest
{ public static void main(String[] args)
{ try
{
if (args.length > 0)
{ String host = args[0];
InetAddress[] addresses
= InetAddress.getAllByName(host);
for (int i = 0; i < addresses.length; i++)
System.out.println(addresses[i]);
}
else
{ InetAddress localHostAddress
= InetAddress.getLocalHost();
System.out.println(localHostAddress);
}
}
catch (Exception e)
{ System.out.println("Error: " + e);
}
}
}