iplookup.java
来自「這是一個修改Oreilly Java 網路程式設計範例的程式 主要是將裡面的一」· Java 代码 · 共 56 行
JAVA
56 行
/*
* 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 + =
减小字号Ctrl + -
显示快捷键?