管理员
|
1#
大中
小发表于 2007-11-30 09:20 只看该作者
java域名解析代码
import java.net.*;
public class NetTool {
InetAddress myIPaddress = null;
InetAddress myServer = null;
public static void main(String args[]) {
NetTool mytool;
mytool = new NetTool();
System.out.println("Your host IP is: " + mytool.getMyIP());
System.out.println("The Server IP is :" + mytool.getServerIP());
}
// 取得LOCALHOST的IP地址
public InetAddress getMyIP() {
try {
myIPaddress = InetAddress.getLocalHost();
} catch (UnknownHostException e) {
}
return (myIPaddress);
}
// 取得 www.abc.com 的IP地址
public InetAddress getServerIP() {
try {
myServer = InetAddress.getByName("www.abc.com");
} catch (UnknownHostException e) {
}
return (myServer);
}
}
换个头像,看见广告就眼红,直接封ID。
|