⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iplookup.java

📁 這是一個修改Oreilly Java 網路程式設計範例的程式 主要是將裡面的一個小程式加上視窗管理者介面方便使用 使用環境: 需有JRE的環境 path需有指到JAVA_HOME下bin/
💻 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 + -