我做了个有关inetaddress的不东西,怎么跑起来起书上面的不一样的啊?
import java.net.*;
public class url05
{
public static void main(String args[])
{
try{
InetAddress address_2=InetAddress.getByName( "220.181.28.50 ");
System.out.println(address_2.toString());
}
catch(
UnknownHostException e)
{
System.out.println( "无法找到222.76.216.23 ");
}
}
}
书上写着:www.****.com**/***.***.***.**之类的,但我跑起来后只显示后面的IP,前面的域名不显示,请问高手是怎么回事啊?
------解决方案--------------------这个我不太懂,但我用的话一般是用域名找IP
import java.net.*;
public class url05
{
public static void main(String args[])
{
try{
InetAddress address_2=InetAddress.getByName( "bbs.csdn.net ");
System.out.println(address_2.toString());
}
catch(UnknownHostException e)
{
System.out.println( "无法找到bbs.csdn.net ");
}
}
}
然后输出一个 "bbs.csdn.net/211.100.21.189 "
不知道你的书上是怎么写的?
------解决方案--------------------System.out.println(address_2);
------解决方案--------------------API