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

📄 ipversion.java

📁 这个程序可以扫描出来本机IP地址的版本号和类别
💻 JAVA
字号:
import java.net.*;
	import java.io.*;
	
	public class IPVersion 
	{
		   public static void main(String args[])
		   {
			 try
			 {
				InetAddress inetadd=InetAddress.getLocalHost();
				byte[ ] address=inetadd.getAddress( );
				if (address.length==4)
				{
	            	  System.out.println("The ip version is ipv4");
	int firstbyte=address[0];
	if (firstbyte<0)
	  firstbyte += 256;
				  if((firstbyte&0x80)==0 )
				  System.out.println("the ip class is A");
				  else if ((firstbyte&0xC0)==0x80 )
				  System.out.println("The ip class is B");
				  else if((firstbyte&0xE0)==0xC0 )
				    System.out.println("The ip class is C");
	                else if((firstbyte&0xF0)==0xE0)
	                   System.out.println("The ip class is D");
	                   else if((firstbyte&0xF8)==0xF0 )
	                      System.out.println("The ip class is E");		   
				}
				else if(address.length==16)
				System.out.println("The ip version is ipv6");
		     }
		     catch (Exception e)
		     { };
		   }
	}

⌨️ 快捷键说明

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