![]() |
#2
liumq2352019-01-17 23:16
|

import *;
public class InetAdressTest {
public static void main(String[] args){
InetAddress address;
try {
address = InetAddress.getByName("http://www.hunnu.);
String Hostaddr1 = address.getHostAddress();
System.out.println("主机IP:" + Hostaddr1);
address = InetAddress.getLocalHost();
String HostName = address.getHostName();
String Hostaddr2 = address.getHostAddress();
System.out.println("本地主机名:" + HostName);
System.out.println("本地主机IP:" + Hostaddr2);
} catch (UnknownHostException e) {
e.printStackTrace();
}
}
}
public class InetAdressTest {
public static void main(String[] args){
InetAddress address;
try {
address = InetAddress.getByName("http://www.hunnu.);
String Hostaddr1 = address.getHostAddress();
System.out.println("主机IP:" + Hostaddr1);
address = InetAddress.getLocalHost();
String HostName = address.getHostName();
String Hostaddr2 = address.getHostAddress();
System.out.println("本地主机名:" + HostName);
System.out.println("本地主机IP:" + Hostaddr2);
} catch (UnknownHostException e) {
e.printStackTrace();
}
}
}
只有本站会员才能查看附件,请 登录