这段程序不能返回IP地址?看看吧!
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);
byte[] ID=new byte[20];
ID=localHostAddress.getAddress();
String SID=localHostAddress.getHostName();
System.out.println(ID);//这里为什么不能返回IP地址? System.out.println(SID);
}
}
catch (Exception e)
{
System.out.println("Error: " + e);
}
}
}
运行结果:
ruanwq/10.16.251.133
[B@53c015
ruanwq
那路朋友看看?
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);
byte[] ID=new byte[20];
ID=localHostAddress.getAddress();
String SID=localHostAddress.getHostName();
System.out.println(ID);//这里为什么不能返回IP地址? System.out.println(SID);
}
}
catch (Exception e)
{
System.out.println("Error: " + e);
}
}
}
运行结果:
ruanwq/10.16.251.133
[B@53c015
ruanwq
那路朋友看看?
...全文
相关推荐
高校技术转移办公室如何实现科技成果的动态管理与多维分析?.docx
科易网基于AI模型+行业大数据,在技术转移、成果转化、技术经纪、知识产权、产业创新、科技招商等垂直领域的多样化应用场景,推出科技创新领域的AI+工具与数智化解决方案,推动科技创新与产业创新智能化发展。
C语言程序设计教程(第6版)课件+例题源文件+习题答案
C语言程序设计教程(第6版)课件+例题源文件+习题答案
自动化生产线控制与维护(基于数字孪生)课件+联调总图+MCD和程序
自动化生产线控制与维护(基于数字孪生)课件+联调总图+MCD和程序
SiLan-EAP-AOI-Test-Case.xlsx222
SiLan-EAP-AOI-Test-Case.xlsx222
电子线路设计与PCB制作 教学课件+教学设计+课后习题
电子线路设计与PCB制作 教学课件+教学设计+课后习题


Java SE
