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

📄 ipaddressseek.java

📁 JAVA网络编程电子书及源码
💻 JAVA
字号:
package net;

/**
 * 在这里插入类型说明。
 * 建立日期:(00-7-31 11:48:16)
 * @程序设计者:
 */
import java.net.*;
 public class IPAddressSeek {
/**
 * IPAddressSeek 构造子注释。
 */
public IPAddressSeek() {
	super();
}
/**
 * 在这里插入方法说明。
 * 建立日期:(00-7-31 11:50:40)
 * @param args java.lang.String[]
 */
public static void main(String[] args) {
	InetAddress hostAddress;
	byte[] integer_address;
	if (args.length==0) {
	    try{
		    hostAddress=InetAddress.getLocalHost();
		    integer_address=hostAddress.getAddress();
		    System.out.println("The domain name of localHost is :\n\t\t\t"+hostAddress.getHostName());
		    System.out.println("The  IP address of localHost in the form of standardDot is :\n\t\t\t"+
			    hostAddress.getHostAddress());
		    System.out.println("The  IP address of localHost in the form of 4_integer_byte is :\n\t\t\t"+
			    integer_address[0]+"\t"+integer_address[1]+"\t"+integer_address[2]+"\t"+integer_address[3]);
		    }catch(UnknownHostException e ) {e.printStackTrace();}
	}
	else {
		try{
		    hostAddress=InetAddress.getByName(args[0]);
		    integer_address=hostAddress.getAddress();
		    System.out.println("The domain name of givenHost is :\n\t\t\t"+hostAddress.getHostName());
		    System.out.println("The  IP address of givenHost is :\n\t\t\t"+hostAddress.getHostAddress());
		    System.out.println("The  IP address of localHost in the form of 4_integer_byte is :\n\t\t\t"+
			    integer_address[0]+"\t"+integer_address[1]+"\t"+integer_address[2]+"\t"+integer_address[3]);
		    }catch(UnknownHostException e ) {e.printStackTrace();}
	}
}
		    
		




		
}

⌨️ 快捷键说明

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