📄 iplookup.java
字号:
/*
* Created on 2005/5/31
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
import java.net.*;
import java.io.*;
/**
* @author avilin
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class IPLookUp {
private String IP;
private String HostName;
public IPLookUp(String IP, String HostName){
this.IP = IP;
this.HostName = HostName;
}
public String LookUpHostName()
{
try
{
InetAddress address = null;
if(this.IP != null)
address = InetAddress.getByName(this.IP);
else
return "HostName is empty";
return address.getHostName();
}catch (Exception e)
{
return "can't find it";
}
}
public String LookUpIP()
{
try
{
InetAddress address= null;
if(this.HostName != null)
address = InetAddress.getByName(this.HostName);
else
return "IP is empty";
return address.getHostAddress() ;
}catch (Exception e)
{
return "can't find it";
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -