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

📄 nslookupapp.java

📁 主要是对于JAVA的编程的基本语言 希望能够帮得上你。
💻 JAVA
字号:
package net;

import java.net.*;
import javax.swing.*;

public class NSLookupApp {
	
	public static void main(String[] args) {				
		
		try {
			String domainName=JOptionPane.showInputDialog
				(null, "输入主机域名:","网络",JOptionPane.INFORMATION_MESSAGE);			
			try {
				if(domainName.equals(""))
					return;
				else{
					InetAddress host=InetAddress.getByName(domainName);
					String hostName=host.getHostName();
//					byte ipAddress[]=host.getAddress();					
//					String strIPAddress="";					
//					for(int i=0;i<ipAddress.length;i++){						
//						if(i!=ipAddress.length-1)
//							strIPAddress=strIPAddress+((ipAddress[i]+256)%256)+".";
//						else
//							strIPAddress=strIPAddress+((ipAddress[i]+256)%256);						
//					}
					
					String strIPAddress=host.getHostAddress();
					
					JOptionPane.showMessageDialog(null, "主机名:"+hostName+"\n"+"IP地址:"+strIPAddress,"域名解析结果",JOptionPane.INFORMATION_MESSAGE);
										
				}
			} catch (RuntimeException e) {				
				JOptionPane.showMessageDialog(null, "你单击了取消按钮!","提示信息",JOptionPane.ERROR_MESSAGE);
			}
		} catch (UnknownHostException e) {			
			JOptionPane.showMessageDialog(null, "未知主机异常!","提示信息",JOptionPane.ERROR_MESSAGE);
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -